ericek111

Untitled

Nov 17th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. package me.lixko.serialsend;
  2.  
  3. import com.fazecast.jSerialComm.SerialPort;
  4.  
  5. public class Main {
  6.  
  7. public static void main(String[] args) throws InterruptedException {
  8. //for(SerialPort sp : SerialPort.getCommPorts()) { System.out.println(sp.getSystemPortName()); }
  9. SerialPort sp = SerialPort.getCommPort("tty.usbmodem1411");
  10. byte[] gpioa = new byte[1];
  11. int p = 0;
  12. boolean direction = true;
  13. while(true) {
  14. if(!sp.isOpen()) sp.openPort();
  15. gpioa[0] = (byte) (1 << p);
  16. sp.writeBytes(gpioa, 1);
  17. if(p < 5 && direction) p++;
  18. else {
  19. direction = false;
  20. p--;
  21. }
  22. if(p == 0 && !direction) direction = true;
  23. //Thread.sleep(200, 100000);
  24. Thread.sleep(200);
  25. }
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment