Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This example will transmit a universe via Art-Net into the Network.
- This example may be copied under the terms of the MIT license, see the LICENSE file for details
- */
- #include <ESP8266WiFi.h>
- #include <WiFiUdp.h>
- #include <ArtnetWifi.h>
- #include <LXESP8266UARTDMX.h>
- int got_dmx = 0;
- int d=1;
- //Wifi settings
- const char* ssid = "ELITEPC"; // CHANGE FOR YOUR SETUP
- const char* password = "qwertyui"; // CHANGE FOR YOUR SETUP
- // Artnet settings
- ArtnetWifi artnet;
- const int startUniverse = 1; // CHANGE FOR YOUR SETUP most software this is 1, some software send out artnet first universe as 0.
- const char host[] = "192.168.0.102"; // CHANGE FOR YOUR SETUP your destination
- // connect to wifi – returns true if successful or false if not
- boolean ConnectWifi(void)
- {
- boolean state = true;
- int i = 0;
- WiFi.begin(ssid, password);
- // Serial.println("");
- //Serial.println("Connecting to WiFi");
- // Wait for connection
- // Serial.print("Connecting");
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- // Serial.print(".");
- if (i > 20){
- state = false;
- break;
- }
- i++;
- }
- if (state){
- // Serial.println("");
- // Serial.print("Connected to ");
- // Serial.println(ssid);
- // Serial.print("IP address: ");
- // Serial.println(WiFi.localIP());
- } else {
- // Serial.println("");
- // Serial.println("Connection failed.");
- }
- return state;
- }
- void setup()
- {
- ConnectWifi();
- artnet.begin(host);
- artnet.setLength(512);
- artnet.setUniverse(startUniverse);
- ESP8266DMX.setDataReceivedCallback(&gotDMXCallback);
- delay(1000); //avoid boot print??
- ESP8266DMX.startInput();
- }
- void gotDMXCallback(int slots) {
- got_dmx = slots;
- }
- void loop()
- {
- int i;
- int j;
- if ( got_dmx ) {
- for(i=0;i<512;i++){
- j=ESP8266DMX.getSlot(d);
- artnet.setByte(i, j);
- d=d+1;
- }
- artnet.write();
- d=1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement