commit 1e1637faadff28114f72d11c8ad8441175952394 Author: Paul Zinselmeyer Date: Wed Aug 28 16:49:32 2024 +0200 init diff --git a/thekenlicht.ino b/thekenlicht.ino new file mode 100644 index 0000000..d050d26 --- /dev/null +++ b/thekenlicht.ino @@ -0,0 +1,38 @@ +#include "DMXUSB.h" + +#define UNIVERSE 0 +#define ADDRESS 1 + +#define RED_PIN 6 +#define GREEN_PIN 9 +#define BLUE_PIN 5 + +#define DMXUSB_BAUDRATE 115200 + +void dmxCallback(int universe, char buffer[512]) { + if (universe == UNIVERSE) { + // DMX-Address starts at one, buffer at zero + analogWrite(RED_PIN, buffer[ADDRESS-1]); + analogWrite(GREEN_PIN, buffer[ADDRESS]); + analogWrite(BLUE_PIN, buffer[ADDRESS+1]); + } +} + +DMXUSB myDMXUsb( + Serial, + DMXUSB_BAUDRATE, + 0, + dmxCallback +); + +void setup() { + // setup pins + pinMode(RED_PIN, OUTPUT); + pinMode(GREEN_PIN, OUTPUT); + pinMode(BLUE_PIN, OUTPUT); + Serial.begin(DMXUSB_BAUDRATE); +} + +void loop() { + myDMXUsb.listen(); +}