thekenlicht/thekenlicht.ino

39 lines
682 B
Arduino
Raw Normal View History

2024-08-28 16:49:32 +02:00
#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();
}