Components and supplies
Wemos D1 Mini
Project description
Code
ArtNet_LED
arduino
DMX over Art-Net to WS2812 sketch.
1#define FASTLED_ALLOW_INTERRUPTS 0 2#include <FastLED.h> 3#include <ESP8266WiFi.h> 4#include <WiFiUdp.h> 5 6//wifi connection 7#define MY_SSID "Network" 8#define MY_PASS "password" 9#define LISTEN_PORT 6454 10WiFiUDP Udp; 11 12//local LEDs 13#define NUM_LEDS 8 14#define LED_PIN D3 15CRGB leds[NUM_LEDS]; 16 17//process incoming UDP message 18void RecieveUdp() 19{ 20 byte packet[18 + (NUM_LEDS * 3)]; 21 22 //test if a packet has been recieved 23 if (Udp.parsePacket() > 0) 24 { 25 //read-in packet and get length 26 int len = Udp.read(packet, 18 + (NUM_LEDS * 3)); 27 28 //discard unread bytes 29 Udp.flush(); 30 31 //test for empty packet 32 if(len < 1) 33 return; 34 35 //test for Art-Net DMX packet 36 //(packet[14] & packet[15] are the low and high bytes for universe) 37 if(packet[9] == 0x50) 38 { 39 int dmx = 18; 40 41 //copy dmx data to leds 42 for(int n = 0; n < NUM_LEDS; n++) 43 leds[n] = CRGB(packet[dmx++], packet[dmx++], packet[dmx++]); 44 45 //push led data 46 FastLED.show(); 47 } 48 } 49} 50 51void setup() 52{ 53 //cennect to WiFi network 54 WiFi.begin(MY_SSID, MY_PASS); 55 Udp.beginPacketMulticast(LISTEN_PORT); 56 57 //start LED port 58 FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS); 59 60 //start serial port 61 //Serial.begin(9600); 62} 63 64void loop() 65{ 66 //get Art-Net 67 RecieveUdp(); 68 69 //wait a spell 70 delay(1); 71} 72
ArtNet_LED
arduino
DMX over Art-Net to WS2812 sketch.
1#define FASTLED_ALLOW_INTERRUPTS 0 2#include <FastLED.h> 3#include 4 <ESP8266WiFi.h> 5#include <WiFiUdp.h> 6 7//wifi connection 8#define MY_SSID 9 "Network" 10#define MY_PASS "password" 11#define LISTEN_PORT 6454 12WiFiUDP 13 Udp; 14 15//local LEDs 16#define NUM_LEDS 8 17#define LED_PIN D3 18CRGB leds[NUM_LEDS]; 19 20//process 21 incoming UDP message 22void RecieveUdp() 23{ 24 byte packet[18 + (NUM_LEDS * 25 3)]; 26 27 //test if a packet has been recieved 28 if (Udp.parsePacket() > 29 0) 30 { 31 //read-in packet and get length 32 int len = Udp.read(packet, 33 18 + (NUM_LEDS * 3)); 34 35 //discard unread bytes 36 Udp.flush(); 37 38 39 //test for empty packet 40 if(len < 1) 41 return; 42 43 //test 44 for Art-Net DMX packet 45 //(packet[14] & packet[15] are the low and high bytes 46 for universe) 47 if(packet[9] == 0x50) 48 { 49 int dmx = 18; 50 51 52 //copy dmx data to leds 53 for(int n = 0; n < NUM_LEDS; n++) 54 leds[n] 55 = CRGB(packet[dmx++], packet[dmx++], packet[dmx++]); 56 57 //push led data 58 59 FastLED.show(); 60 } 61 } 62} 63 64void setup() 65{ 66 //cennect 67 to WiFi network 68 WiFi.begin(MY_SSID, MY_PASS); 69 Udp.beginPacketMulticast(LISTEN_PORT); 70 71 72 //start LED port 73 FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS); 74 75 76 //start serial port 77 //Serial.begin(9600); 78} 79 80void loop() 81{ 82 83 //get Art-Net 84 RecieveUdp(); 85 86 //wait a spell 87 delay(1); 88} 89
Downloadable files
Drawing
Drawing
Comments
Only logged in users can leave comments
jackguy
0 Followers
•0 Projects
Table of contents
Intro
1
0