This commit is contained in:
2025-01-08 23:23:16 -06:00
commit d514bc8e5c
8 changed files with 245 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
#include <DMXSerial.h>
#include <Arduino.h>
// const int DIP_PINS[8] = {13, 14, 15, 16, 17, 18, 19, 2};
const int RELAY_PINS[8] = {3, 4, 5, 6, 7, 8, 9, 10};
int DMXChannelStart = 400;
void setup() {
DMXSerial.init(DMXReceiver);
for (int i = 0; i < 8; i++) {
DMXSerial.write(DMXChannelStart + i, 0);
// pinMode(DIP_PINS[i], INPUT);
pinMode(RELAY_PINS[i], OUTPUT);
}
}
void loop() {
// Calculate how long no data bucket was received
unsigned long lastPacket = DMXSerial.noDataSince();
// for (int i = 0; i < 8; i++) {
// DMXChannelStart |= (!digitalRead(DIP_PINS[i])) << i;
// }
if (lastPacket < 5000) {
for (int i = 0; i < 8; i++) {
if (DMXSerial.read(DMXChannelStart + i) > (uint8_t)127) {
digitalWrite(RELAY_PINS[i], HIGH);
} else {
digitalWrite(RELAY_PINS[i], LOW);
}
}
} else {
for (int i = 0; i < 8; i++) {
digitalWrite(RELAY_PINS[i], LOW);
}
}
delay(50);
}