add arduino files
parent
6e89f4aa9f
commit
a8c2813b74
@ -0,0 +1,62 @@
|
||||
//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);
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
//DMX stuff
|
||||
#include <ArduinoRS485.h>
|
||||
#include <ArduinoDMX.h>
|
||||
const int universeSize = 512;
|
||||
|
||||
//ArtNet stuff
|
||||
#include <UIPArtnet.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(30, data[i]);
|
||||
if (i == 1) analogWrite(8, data[i]);
|
||||
if (i == 2) analogWrite(9, data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
pinMode(30, OUTPUT);
|
||||
pinMode(8, OUTPUT);
|
||||
pinMode(9, OUTPUT);
|
||||
|
||||
pinMode(13, OUTPUT);
|
||||
|
||||
//pinMode(7, 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(13, HIGH);
|
||||
}
|
||||
//analogWrite(9, 255);
|
||||
|
||||
|
||||
DMX.beginTransmission();
|
||||
for (int i = 0; i <= 511; ++i) {
|
||||
DMX.write(i, artnetdata[i]);
|
||||
}
|
||||
DMX.endTransmission();
|
||||
delay(20);
|
||||
digitalWrite(13, LOW);
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
//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;
|
||||
byte 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(byte* data, uint16_t size) {
|
||||
for (size_t i = 0; i < 512; ++i) {
|
||||
artnetdata[i] = data[i];
|
||||
if (i == 0) analogWrite(3, data[i]);
|
||||
if (i == 1) analogWrite(5, data[i]);
|
||||
if (i == 2) analogWrite(6, data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//NRF stuff
|
||||
#include <SPI.h>
|
||||
#include <RF24.h>
|
||||
#include <nRF24L01.h>
|
||||
|
||||
RF24 radio (7, 8);
|
||||
|
||||
const uint16_t address = 0xADB0;
|
||||
uint64_t datasend;
|
||||
|
||||
//setup
|
||||
void setup() {
|
||||
pinMode(3, OUTPUT);
|
||||
pinMode(5, OUTPUT);
|
||||
pinMode(6, OUTPUT);
|
||||
|
||||
pinMode(9, OUTPUT);
|
||||
|
||||
//start DMX
|
||||
DMX.begin(universeSize);
|
||||
|
||||
//start ethernet
|
||||
Ethernet.begin(mac, ip);
|
||||
|
||||
//start ArtNet
|
||||
artnet.begin();
|
||||
artnet.subscribe(universe0, callback);
|
||||
|
||||
//start NRF
|
||||
radio.begin();
|
||||
radio.openWritingPipe(address);
|
||||
radio.setPALevel(RF24_PA_MIN);
|
||||
radio.setDataRate(RF24_1MBPS);
|
||||
//radio.disableDynamicPayloads();
|
||||
radio.setAutoAck(false);
|
||||
radio.disableCRC();
|
||||
radio.stopListening();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int timebegin = millis();
|
||||
|
||||
//get ArtNet package
|
||||
if (artnet.parse()) { // check if artnet packet has come and execute callback
|
||||
digitalWrite(9, HIGH);
|
||||
}
|
||||
|
||||
//uint64_t nrfpackage = artnetdata[0];
|
||||
|
||||
|
||||
//DMX output
|
||||
DMX.beginTransmission();
|
||||
for (int i = 0; i < 512; ++i) {
|
||||
DMX.write(i, artnetdata[i]);
|
||||
}
|
||||
DMX.endTransmission();
|
||||
|
||||
//send NRF
|
||||
for (int i = 0; i < 20; i++) {
|
||||
datasend = i; //package ID
|
||||
|
||||
for (int j = 0; j < 7; j++) {
|
||||
datasend = (datasend << 8) + artnetdata[7 * i + j];
|
||||
}
|
||||
radio.writeFast(&datasend, sizeof(datasend));
|
||||
}
|
||||
|
||||
int timeend = millis();
|
||||
int timeneeded = timeend - timebegin;
|
||||
|
||||
if (timeneeded < 20) delay(20 - timeneeded);
|
||||
|
||||
digitalWrite(9, LOW);
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
//DMX stuff
|
||||
#include <ArduinoRS485.h>
|
||||
#include <ArduinoDMX.h>
|
||||
const int universeSize = 512;
|
||||
|
||||
//ArtNet stuff
|
||||
#include <UIPArtnet.h>
|
||||
ArtnetReceiver artnet;
|
||||
uint32_t universe0 = 0;
|
||||
uint32_t universe1 = 1;
|
||||
byte 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(byte* data, uint16_t size) {
|
||||
for (size_t i = 0; i < 512; ++i) {
|
||||
artnetdata[i] = data[i];
|
||||
//if (i == 0) analogWrite(30, data[i]);
|
||||
//if (i == 1) analogWrite(8, data[i]);
|
||||
//if (i == 2) analogWrite(9, data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//NRF stuff
|
||||
#include <SPI.h>
|
||||
#include <RF24.h>
|
||||
#include <nRF24L01.h>
|
||||
|
||||
RF24 radio (0, 1);
|
||||
|
||||
const uint16_t address = 0xADB0;
|
||||
uint64_t datasend;
|
||||
|
||||
//setup
|
||||
void setup() {
|
||||
pinMode(12, OUTPUT);
|
||||
pinMode(13, OUTPUT);
|
||||
pinMode(14, OUTPUT);
|
||||
|
||||
pinMode(15, OUTPUT);
|
||||
|
||||
//start DMX
|
||||
DMX.begin(universeSize);
|
||||
|
||||
//start ethernet
|
||||
Ethernet.begin(mac, ip);
|
||||
|
||||
//start ArtNet
|
||||
artnet.begin();
|
||||
artnet.subscribe(universe0, callback);
|
||||
|
||||
//start NRF
|
||||
radio.begin();
|
||||
radio.openWritingPipe(address);
|
||||
radio.setPALevel(RF24_PA_LOW);
|
||||
radio.setDataRate(RF24_1MBPS);
|
||||
//radio.disableDynamicPayloads();
|
||||
radio.setAutoAck(false);
|
||||
radio.disableCRC();
|
||||
radio.stopListening();
|
||||
|
||||
analogWrite(12, 20);
|
||||
delay(100);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//int timebegin = millis();
|
||||
|
||||
//get ArtNet package
|
||||
while(!artnet.parse());
|
||||
digitalWrite(15, HIGH);
|
||||
/*if (artnet.parse()) { // check if artnet packet has come and execute callback
|
||||
digitalWrite(31, HIGH);
|
||||
}*/
|
||||
|
||||
//uint64_t nrfpackage = artnetdata[0];
|
||||
|
||||
//RGB PWM
|
||||
analogWrite(12, artnetdata[0]);
|
||||
analogWrite(13, artnetdata[1]);
|
||||
analogWrite(14, artnetdata[2]);
|
||||
|
||||
//DMX output
|
||||
DMX.beginTransmission();
|
||||
for (int i = 0; i < 512; ++i) {
|
||||
DMX.write(i, artnetdata[i]);
|
||||
}
|
||||
DMX.endTransmission();
|
||||
|
||||
//send NRF
|
||||
for (int i = 0; i < 20; i++) {
|
||||
datasend = i; //package ID
|
||||
|
||||
for (int j = 0; j < 7; j++) {
|
||||
datasend = (datasend << 8) + artnetdata[7 * i + j];
|
||||
}
|
||||
radio.writeFast(&datasend, sizeof(datasend));
|
||||
}
|
||||
|
||||
//int timeend = millis();
|
||||
//int timeneeded = timeend - timebegin;
|
||||
|
||||
//if (timeneeded < 20) delay(20 - timeneeded);
|
||||
|
||||
digitalWrite(15, LOW);
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
//DMX stuff
|
||||
#include <ArduinoRS485.h>
|
||||
#include <ArduinoDMX.h>
|
||||
const int universeSize = 512;
|
||||
|
||||
//Neopixel stuff
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#ifdef __AVR__
|
||||
#include <avr/power.h>
|
||||
#endif
|
||||
#define NEOPIN 11
|
||||
#define NUMPIXELS 50
|
||||
#define NEOSTART 0
|
||||
Adafruit_NeoPixel pixels(NUMPIXELS, NEOPIN, NEO_GRB + NEO_KHZ800);
|
||||
|
||||
//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(3, 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);
|
||||
|
||||
//start DMX
|
||||
DMX.begin(universeSize);
|
||||
|
||||
//start Neopixels
|
||||
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
|
||||
clock_prescale_set(clock_div_1);
|
||||
#endif
|
||||
|
||||
pixels.begin();
|
||||
|
||||
//start ethernet
|
||||
Ethernet.begin(mac, ip);
|
||||
|
||||
//start ArtNet
|
||||
artnet.begin();
|
||||
artnet.subscribe(universe0, callback);
|
||||
|
||||
//pinMode(10, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (artnet.parse()) { // check if artnet packet has come and execute callback
|
||||
digitalWrite(9, HIGH);
|
||||
}
|
||||
|
||||
DMX.beginTransmission(); //beginn DMX
|
||||
|
||||
|
||||
for (int i = 0; i <= 511; ++i) {
|
||||
DMX.write(i, artnetdata[i]); //write DMX data
|
||||
}
|
||||
DMX.endTransmission();
|
||||
|
||||
pixels.clear(); //clear Neopixels
|
||||
for (int i = 0; i < 48; ++i) {
|
||||
pixels.setPixelColor(i, pixels.Color(artnetdata[i * 3 + 0 + NEOSTART], artnetdata[i * 3 + 1 + NEOSTART], artnetdata[i * 3 + 2 + NEOSTART])); //write Neopixel data
|
||||
}
|
||||
pixels.show(); //send Neopixel data
|
||||
|
||||
delay(20);
|
||||
digitalWrite(9, LOW);
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
//DMX stuff
|
||||
#include <ArduinoRS485.h>
|
||||
#include <ArduinoDMX.h>
|
||||
const int universeSize = 512;
|
||||
byte DMXdata[512];
|
||||
|
||||
//Neopixel stuff
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#ifdef __AVR__
|
||||
#include <avr/power.h>
|
||||
#endif
|
||||
#define NEOPIN 10
|
||||
#define NUMPIXELS 1
|
||||
#define NEOSTART 0
|
||||
Adafruit_NeoPixel pixels(NUMPIXELS, NEOPIN, NEO_GRB + NEO_KHZ800);
|
||||
|
||||
//NRF stuff
|
||||
#include <SPI.h>
|
||||
#include <RF24.h>
|
||||
#include <nRF24L01.h>
|
||||
|
||||
RF24 radio (7, 8);
|
||||
|
||||
const uint16_t address = 0xADB0;
|
||||
uint64_t datareceive;
|
||||
|
||||
void setup() {
|
||||
//Serial.begin(115200);
|
||||
|
||||
pinMode(3, OUTPUT);
|
||||
pinMode(5, OUTPUT);
|
||||
pinMode(6, OUTPUT);
|
||||
|
||||
pinMode(9, OUTPUT);
|
||||
|
||||
|
||||
//start NRF
|
||||
radio.begin();
|
||||
radio.openReadingPipe(0, address);
|
||||
radio.setPALevel(RF24_PA_MAX);
|
||||
radio.setDataRate(RF24_1MBPS);
|
||||
radio.setAutoAck(false);
|
||||
radio.disableCRC();
|
||||
radio.startListening();
|
||||
|
||||
//start DMX
|
||||
DMX.begin(universeSize);
|
||||
|
||||
//Serial.println("setup finished");
|
||||
|
||||
//start Neopixels
|
||||
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
|
||||
clock_prescale_set(clock_div_1);
|
||||
#endif
|
||||
|
||||
pixels.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
for (int i = 0; i < 20; i++) { //count packages
|
||||
do {
|
||||
while (!radio.available()); //wait for NRF
|
||||
radio.read(&datareceive, sizeof(datareceive)); //get NRF data
|
||||
} while (i != ((datareceive >> 8 * 7) & 0xFF)); //wait for right package ID
|
||||
digitalWrite(9, HIGH);
|
||||
for (int j = 0; j < 7; j++) { //count bytes
|
||||
DMXdata[7 * i + j] = (datareceive >> 48 - 8 * j) & 0xFF; //bytes to array
|
||||
//Serial.print(DMXdata[7 * i + j], HEX); //print data
|
||||
//Serial.print(", ");
|
||||
}
|
||||
}
|
||||
//Serial.println("");
|
||||
//DMX output
|
||||
DMX.beginTransmission();
|
||||
for (int i = 0; i < 280; ++i) {
|
||||
DMX.write(i, DMXdata[i]);
|
||||
//if (i == 0) analogWrite(3, DMXdata[i]);
|
||||
//if (i == 1) analogWrite(5, DMXdata[i]);
|
||||
//if (i == 2) analogWrite(6, DMXdata[i]);
|
||||
}
|
||||
DMX.endTransmission();
|
||||
|
||||
pixels.clear();
|
||||
pixels.setPixelColor(0, pixels.Color(DMXdata[1], DMXdata[0], DMXdata[2]));
|
||||
pixels.show();
|
||||
|
||||
digitalWrite(9, LOW);
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
//NRF stuff
|
||||
#include <SPI.h>
|
||||
#include <RF24.h>
|
||||
#include <nRF24L01.h>
|
||||
|
||||
RF24 radio (7, 8);
|
||||
|
||||
const uint16_t address = 0xADB0;
|
||||
uint64_t datareceive;
|
||||
|
||||
//Neopixel stuff
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#ifdef __AVR__
|
||||
#include <avr/power.h>
|
||||
#endif
|
||||
#define NEOPIN 6
|
||||
#define NUMPIXELS 48
|
||||
#define NEOSTART 0
|
||||
Adafruit_NeoPixel pixels(NUMPIXELS, NEOPIN, NEO_GRB + NEO_KHZ800);
|
||||
byte neodata[512];
|
||||
|
||||
void setup() {
|
||||
pinMode(9, OUTPUT);
|
||||
|
||||
//start NRF
|
||||
radio.begin();
|
||||
radio.openReadingPipe(0, address);
|
||||
radio.setPALevel(RF24_PA_LOW);
|
||||
radio.setDataRate(RF24_1MBPS);
|
||||
radio.setAutoAck(false);
|
||||
radio.disableCRC();
|
||||
radio.startListening();
|
||||
|
||||
//start Neopixels
|
||||
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
|
||||
clock_prescale_set(clock_div_1);
|
||||
#endif
|
||||
pixels.begin();
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//NRF receive
|
||||
for (int i = 0; i < 20; i++) { //count packages
|
||||
do {
|
||||
while (!radio.available()); //wait for NRF
|
||||
radio.read(&datareceive, sizeof(datareceive)); //get NRF data
|
||||
} while (i != ((datareceive >> 8 * 7) & 0xFF)); //wait for right package ID
|
||||
digitalWrite(9, HIGH);
|
||||
for (int j = 0; j < 7; j++) { //count bytes
|
||||
neodata[7 * i + j] = (datareceive >> 48 - 8 * j) & 0xFF; //bytes to array
|
||||
//Serial.print(DMXdata[7 * i + j], HEX); //print data
|
||||
//Serial.print(", ");
|
||||
}
|
||||
}
|
||||
|
||||
pixels.clear(); //clear Neopixels
|
||||
for (int i = 0; i < 48; ++i) {
|
||||
pixels.setPixelColor(i, pixels.Color(neodata[i * 3 + 0 + NEOSTART], neodata[i * 3 + 1 + NEOSTART], neodata[i * 3 + 2 + NEOSTART])); //write Neopixel data
|
||||
}
|
||||
pixels.show(); //send Neopixel data
|
||||
|
||||
digitalWrite(9, LOW);
|
||||
}
|
Loading…
Reference in New Issue