Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.lixko.serialsend;
- import com.fazecast.jSerialComm.SerialPort;
- public class Main {
- public static void main(String[] args) throws InterruptedException {
- //for(SerialPort sp : SerialPort.getCommPorts()) { System.out.println(sp.getSystemPortName()); }
- SerialPort sp = SerialPort.getCommPort("tty.usbmodem1411");
- byte[] gpioa = new byte[1];
- int p = 0;
- boolean direction = true;
- while(true) {
- if(!sp.isOpen()) sp.openPort();
- gpioa[0] = (byte) (1 << p);
- sp.writeBytes(gpioa, 1);
- if(p < 5 && direction) p++;
- else {
- direction = false;
- p--;
- }
- if(p == 0 && !direction) direction = true;
- //Thread.sleep(200, 100000);
- Thread.sleep(200);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment