You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.2 KiB
C++
63 lines
1.2 KiB
C++
//DMX stuff
|
|
#include <ArduinoRS485.h>
|
|
#include <ArduinoDMX.h>
|
|
const int universeSize = 512;
|
|
|
|
//ArtNet stuff
|
|
#include <Artnet.h>
|
|
ArtnetReceiver artnet;
|
|
uint32_t universe0 = 0;
|
|
uint32_t universe1 = 1;
|
|
int artnetdata[512];
|
|
|
|
// ethernet stuff
|
|
const IPAddress ip(10, 255, 255, 255);
|
|
uint8_t mac[] = {0xAA, 0xDD, 0xBB, 0xAA, 0xDD, 0xBB};
|
|
|
|
//ArtNet universe0 callback
|
|
void callback(uint8_t* data, uint16_t size) {
|
|
for (size_t i = 0; i <= 511; ++i) {
|
|
artnetdata[i] = data[i];
|
|
if (i == 0) analogWrite(12, data[i]);
|
|
if (i == 1) analogWrite(5, data[i]);
|
|
if (i == 2) analogWrite(6, data[i]);
|
|
}
|
|
}
|
|
|
|
void setup() {
|
|
pinMode(3, OUTPUT);
|
|
pinMode(5, OUTPUT);
|
|
pinMode(6, OUTPUT);
|
|
|
|
pinMode(9, OUTPUT);
|
|
|
|
pinMode(12, OUTPUT);
|
|
|
|
//start DMX
|
|
DMX.begin(universeSize);
|
|
|
|
//start ethernet
|
|
Ethernet.begin(mac, ip);
|
|
|
|
//start ArtNet
|
|
artnet.begin();
|
|
artnet.subscribe(universe0, callback);
|
|
}
|
|
|
|
void loop() {
|
|
//analogWrite(9, 85);
|
|
if (artnet.parse()){ // check if artnet packet has come and execute callback
|
|
digitalWrite(9, HIGH);
|
|
}
|
|
//analogWrite(9, 255);
|
|
|
|
|
|
DMX.beginTransmission();
|
|
for (int i = 0; i <= 511; ++i) {
|
|
DMX.write(i, artnetdata[i]);
|
|
}
|
|
DMX.endTransmission();
|
|
delay(20);
|
|
digitalWrite(9, LOW);
|
|
}
|