(WIP) RGB controller on Arduino w/ sync to main PC system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

control.py 469B

12345678910111213141516171819202122
  1. import serial
  2. import sys
  3. import time
  4. import struct
  5. ser = serial.Serial()
  6. ser.port = sys.argv[1]
  7. ser.baudrate = 115200
  8. ser.open()
  9. time.sleep(2)
  10. while True:
  11. line = sys.stdin.readline().strip().upper()
  12. if line == "EXIT":
  13. break
  14. arr = line.split(" ")
  15. bytesToWrite = arr[0].encode("ascii") + b" "
  16. if len(arr) > 1:
  17. for i in range(1, len(arr)):
  18. bytesToWrite += struct.pack("B", int(arr[i]))
  19. bytesToWrite += b"\n"
  20. ser.write(bytesToWrite)
  21. ser.close()