PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
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.

SerialToDmx.pde 1.1KB

3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* This program allows you to set DMX channels over the serial port.
  2. **
  3. ** After uploading to Arduino, switch to Serial Monitor and set the baud rate
  4. ** to 9600. You can then set DMX channels using these commands:
  5. **
  6. ** <number>c : Select DMX channel
  7. ** <number>v : Set DMX channel to new value
  8. **
  9. ** These can be combined. For example:
  10. ** 100c355w : Set channel 100 to value 255.
  11. **
  12. ** For more details, and compatible Processing sketch,
  13. ** visit http://code.google.com/p/tinkerit/wiki/SerialToDmx
  14. **
  15. ** Help and support: http://groups.google.com/group/dmxsimple */
  16. #include <DmxSimple.h>
  17. void setup() {
  18. Serial.begin(9600);
  19. Serial.println("SerialToDmx ready");
  20. Serial.println();
  21. Serial.println("Syntax:");
  22. Serial.println(" 123c : use DMX channel 123");
  23. Serial.println(" 45w : set current channel to value 45");
  24. }
  25. int value = 0;
  26. int channel;
  27. void loop() {
  28. int c;
  29. while(!Serial.available());
  30. c = Serial.read();
  31. if ((c>='0') && (c<='9')) {
  32. value = 10*value + c - '0';
  33. } else {
  34. if (c=='c') channel = value;
  35. else if (c=='w') {
  36. DmxSimple.write(channel, value);
  37. Serial.println();
  38. }
  39. value = 0;
  40. }
  41. }