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.

41 lines
767 B

7 years ago
  1. #include <WS2812.h>
  2. #include <DigiCDC.h>
  3. #define LEDCount 37
  4. #define outputPin 1
  5. WS2812 LED(LEDCount);
  6. cRGB value;
  7. void setup() {
  8. SerialUSB.begin();
  9. LED.setOutput(outputPin);
  10. }
  11. void loop() {
  12. if (SerialUSB.available() > 1 && SerialUSB.read() == 0x10) {
  13. byte command = SerialUSB.read();
  14. if (command == 0x11) {
  15. LED.sync();
  16. SerialUSB.write(0x1f);
  17. }
  18. else if (command == 0x12) {
  19. while (SerialUSB.available() < 4) {
  20. }
  21. int pos = SerialUSB.read();
  22. value.r = SerialUSB.read();
  23. value.g = SerialUSB.read();
  24. value.b = SerialUSB.read();
  25. LED.set_crgb_at(pos, value);
  26. SerialUSB.write(0x1f);
  27. }
  28. else {
  29. SerialUSB.write(0x1e);
  30. }
  31. SerialUSB.flush();
  32. }
  33. }