#include #include #define DMX_SLAVE_CHANNELS 5 DMX_Slave dmx_slave ( DMX_SLAVE_CHANNELS ); const int ledPin = 13; //**************************Zuweisung 230V Ausgänge und Statusanzeige Funkkanäle************************************** const int CH1 = 30; const int CH2 = 31; const int CH3 = 32; const int CH4 = 33; const int CH5 = 34; const int CH6 = 35; const int CH7 = 36; const int CH8 = 37; //*****************************Zuweisung DIP Schalter für Addressierung*********************************************** const int S1 = 11; const int S2 = 22; const int S3 = 23; const int S4 = 24; const int S5 = 25; const int S6 = 26; const int S7 = 27; const int S8 = 28; const int S9 = 29; int DMXaddress = 0; int lastS1 = 0; int lastS2 = 0; int lastS3 = 0; int lastS4 = 0; int lastS5 = 0; int lastS6 = 0; int lastS7 = 0; int lastS8 = 0; int lastS9 = 0; void setup() { vw_set_ptt_inverted(true); // Required for DR3100 vw_setup(2000); // Bits per sec // Enable DMX slave interface and start recording // DMX data dmx_slave.enable (); // Set start address to 1, this is also the default setting // You can change this address at any time during the program dmx_slave.setStartAddress (1); // Set led pin as output pin pinMode ( ledPin, OUTPUT ); //*************************Zuweisung DIP Schalter für Addressierung als Eingang************************************ pinMode (S1, INPUT); pinMode (S2, INPUT); pinMode (S3, INPUT); pinMode (S4, INPUT); pinMode (S5, INPUT); pinMode (S6, INPUT); pinMode (S7, INPUT); pinMode (S8, INPUT); pinMode (S9, INPUT); //*************************Zuweisung 230V Ausgänge und Statusanzeige Funkkanäle als Ausgang************************ pinMode (CH1, OUTPUT); pinMode (CH2, OUTPUT); pinMode (CH3, OUTPUT); pinMode (CH4, OUTPUT); pinMode (CH5, OUTPUT); pinMode (CH6, OUTPUT); pinMode (CH7, OUTPUT); pinMode (CH8, OUTPUT); } void loop() { senden (); //dmxaddress (); //dmx_slave.setStartAddress (DMXaddress); } /*void dmxaddress () //Einstellen der DMX Addresse { if (digitalRead (S1) == HIGH && !lastS1) { DMXaddress = DMXaddress+1; lastS1 = 1; } if (digitalRead(S1)== LOW && lastS1) { DMXaddress = DMXaddress-1; lastS1 = 0; } if (digitalRead (S2) == HIGH && !lastS2) { DMXaddress = DMXaddress+2; lastS2 = 1; } if (digitalRead(S2)== LOW && lastS2) { DMXaddress = DMXaddress-2; lastS2 = 0; } if (digitalRead (S3) == HIGH && !lastS3) { DMXaddress = DMXaddress+4; lastS3 = 1; } if (digitalRead(S3)== LOW && lastS3) { DMXaddress = DMXaddress-4; lastS3 = 0; } if (digitalRead (S4) == HIGH && !lastS4) { DMXaddress = DMXaddress+8; lastS4 = 1; } if (digitalRead(S4)== LOW && lastS4) { DMXaddress = DMXaddress-8; lastS4 = 0; } if (digitalRead (S5) == HIGH && !lastS5) { DMXaddress = DMXaddress+16; lastS5 = 1; } if (digitalRead(S5)== LOW && lastS5) { DMXaddress = DMXaddress-16; lastS5 = 0; } if (digitalRead (S6) == HIGH && !lastS6) { DMXaddress = DMXaddress+32; lastS6 = 1; } if (digitalRead(S6)== LOW && lastS6) { DMXaddress = DMXaddress-32; lastS6 = 0; } if (digitalRead (S7) == HIGH && !lastS7) { DMXaddress = DMXaddress+64; lastS7 = 1; } if (digitalRead(S7)== LOW && lastS7) { DMXaddress = DMXaddress-64; lastS7 = 0; } if (digitalRead (S8) == HIGH && !lastS8) { DMXaddress = DMXaddress+128; lastS8 = 1; } if (digitalRead(S8)== LOW && lastS8) { DMXaddress = DMXaddress-128; lastS8 = 0; } if (digitalRead (S9) == HIGH && !lastS9) { DMXaddress = DMXaddress+256; lastS9 = 1; } if (digitalRead(S9)== LOW && lastS9) { DMXaddress = DMXaddress-256; lastS9 = 0; } }*/ void senden () //Auswertung der DMX Signale und senden an Empfänger { if ( dmx_slave.getChannelValue (1) > 127 ) //Wenn CH1 auf 1 { const char *msg = "CH1_1"; //Sende CH1_1 vw_send((uint8_t *)msg, strlen(msg)); vw_wait_tx(); //Warten bis gesendet //delay(200); digitalWrite(CH1, true); //Statusanzeige Kanal digitalWrite(13, true); } else { const char *msg = "CH1_0"; //Sende CH1_0 vw_send((uint8_t *)msg, strlen(msg)); vw_wait_tx(); //Warten bis gesendet // delay(200); digitalWrite(CH1, false); //Statusanzeige Kanal digitalWrite(13, false); } if ( dmx_slave.getChannelValue (2) > 127 ) //Wenn CH1 auf 1 { const char *msg = "CH2_1"; //Sende CH1_1 vw_send((uint8_t *)msg, strlen(msg)); vw_wait_tx(); //Warten bis gesendet //delay(200); digitalWrite(CH2, true); //Statusanzeige Kanal } else { const char *msg = "CH2_0"; //Sende CH1_0 vw_send((uint8_t *)msg, strlen(msg)); vw_wait_tx(); //Warten bis gesendet // delay(200); digitalWrite(CH2, false); //Statusanzeige Kanal } if ( dmx_slave.getChannelValue (3) > 127 ) //Wenn CH1 auf 1 { const char *msg = "CH3_1"; //Sende CH1_1 vw_send((uint8_t *)msg, strlen(msg)); vw_wait_tx(); //Warten bis gesendet //delay(200); digitalWrite(CH3, true); //Statusanzeige Kanal } else { const char *msg = "CH3_0"; //Sende CH1_0 vw_send((uint8_t *)msg, strlen(msg)); vw_wait_tx(); //Warten bis gesendet // delay(200); digitalWrite(CH3, false); //Statusanzeige Kanal } if ( dmx_slave.getChannelValue (4) > 127 ) //Wenn CH1 auf 1 { const char *msg = "CH4_1"; //Sende CH1_1 vw_send((uint8_t *)msg, strlen(msg)); vw_wait_tx(); //Warten bis gesendet //delay(200); digitalWrite(CH4, true); //Statusanzeige Kanal } else { const char *msg = "CH4_0"; //Sende CH1_0 vw_send((uint8_t *)msg, strlen(msg)); vw_wait_tx(); //Warten bis gesendet // delay(200); digitalWrite(CH4, false); //Statusanzeige Kanal } if ( dmx_slave.getChannelValue (5) > 127 ) //Wenn CH1 auf 1 { const char *msg = "CH5_1"; //Sende CH1_1 vw_send((uint8_t *)msg, strlen(msg)); vw_wait_tx(); //Warten bis gesendet //delay(200); digitalWrite(CH5, true); //Statusanzeige Kanal } else { const char *msg = "CH5_0"; //Sende CH1_0 vw_send((uint8_t *)msg, strlen(msg)); vw_wait_tx(); //Warten bis gesendet // delay(200); digitalWrite(CH5, false); //Statusanzeige Kanal }