Advertisement
NapsterMP3

DMX to ARTNET com WIFI

Jun 8th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. /*
  2. This example will transmit a universe via Art-Net into the Network.
  3. This example may be copied under the terms of the MIT license, see the LICENSE file for details
  4. */
  5.  
  6. #include <ESP8266WiFi.h>
  7. #include <WiFiUdp.h>
  8. #include <ArtnetWifi.h>
  9. #include <LXESP8266UARTDMX.h>
  10.  
  11. int got_dmx = 0;
  12. int d=1;
  13.  
  14.  
  15. //Wifi settings
  16. const char* ssid = "ELITEPC"; // CHANGE FOR YOUR SETUP
  17. const char* password = "qwertyui"; // CHANGE FOR YOUR SETUP
  18.  
  19. // Artnet settings
  20. ArtnetWifi artnet;
  21. const int startUniverse = 1; // CHANGE FOR YOUR SETUP most software this is 1, some software send out artnet first universe as 0.
  22. const char host[] = "192.168.0.102"; // CHANGE FOR YOUR SETUP your destination
  23.  
  24. // connect to wifi – returns true if successful or false if not
  25. boolean ConnectWifi(void)
  26. {
  27. boolean state = true;
  28. int i = 0;
  29.  
  30. WiFi.begin(ssid, password);
  31. // Serial.println("");
  32. //Serial.println("Connecting to WiFi");
  33.  
  34. // Wait for connection
  35. // Serial.print("Connecting");
  36. while (WiFi.status() != WL_CONNECTED) {
  37. delay(500);
  38. // Serial.print(".");
  39. if (i > 20){
  40. state = false;
  41. break;
  42. }
  43. i++;
  44. }
  45. if (state){
  46. // Serial.println("");
  47. // Serial.print("Connected to ");
  48. // Serial.println(ssid);
  49. // Serial.print("IP address: ");
  50. // Serial.println(WiFi.localIP());
  51. } else {
  52. // Serial.println("");
  53. // Serial.println("Connection failed.");
  54. }
  55.  
  56. return state;
  57. }
  58.  
  59. void setup()
  60. {
  61. ConnectWifi();
  62. artnet.begin(host);
  63. artnet.setLength(512);
  64. artnet.setUniverse(startUniverse);
  65. ESP8266DMX.setDataReceivedCallback(&gotDMXCallback);
  66. delay(1000); //avoid boot print??
  67. ESP8266DMX.startInput();
  68. }
  69.  
  70. void gotDMXCallback(int slots) {
  71. got_dmx = slots;
  72. }
  73.  
  74. void loop()
  75. {
  76. int i;
  77. int j;
  78.  
  79. if ( got_dmx ) {
  80.  
  81. for(i=0;i<512;i++){
  82.  
  83. j=ESP8266DMX.getSlot(d);
  84. artnet.setByte(i, j);
  85. d=d+1;
  86. }
  87. artnet.write();
  88. d=1;
  89. }
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement