//DMX stuff #include #include const int universeSize = 512; byte DMXdata[512]; //Neopixel stuff #include #ifdef __AVR__ #include #endif #define NEOPIN 10 #define NUMPIXELS 1 #define NEOSTART 0 Adafruit_NeoPixel pixels(NUMPIXELS, NEOPIN, NEO_GRB + NEO_KHZ800); //NRF stuff #include #include #include 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_2MBPS); 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); }