├── ArtNetWS2812_3.ino └── README.md /ArtNetWS2812_3.ino: -------------------------------------------------------------------------------- 1 | // ArtNetWS2812 2 | // Requires Teensy 4.1 + Teensy Ethernet Kit 3 | // Make sure to alter the "Artnet" library that ships with Teensyduino to point to "" & "" 4 | // Code adapted from the original example: https://github.com/natcl/Artnet/blob/master/examples/NeoPixel/ArtnetNeoPixel/ArtnetNeoPixel.ino 5 | 6 | /* 7 | This example will receive multiple universes via Artnet and control a strip of ws2811 leds via 8 | Adafruit's NeoPixel library: https://github.com/adafruit/Adafruit_NeoPixel 9 | This example may be copied under the terms of the MIT license, see the LICENSE file for details 10 | */ 11 | 12 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | // Neopixel settings 21 | const int numLeds = 232; // change for your setup 22 | const int numberOfChannels = numLeds * 3; // Total number of channels you want to receive (1 led = 3 channels) 23 | const byte dataPin = 2; 24 | Adafruit_NeoPixel leds = Adafruit_NeoPixel(numLeds, dataPin, NEO_GRB + NEO_KHZ800); 25 | 26 | // Artnet settings 27 | Artnet artnet; 28 | const int startUniverse = 0; // CHANGE FOR YOUR SETUP most software this is 1, some software send out artnet first universe as 0. 29 | 30 | // Check if we got all universes 31 | const int maxUniverses = numberOfChannels / 512 + ((numberOfChannels % 512) ? 1 : 0); 32 | bool universesReceived[maxUniverses]; 33 | bool sendFrame = 1; 34 | int previousDataLength = 0; 35 | 36 | // Change ip and mac address for your setup 37 | byte ip[] = {192, 168, 2, 222}; 38 | byte mac[] = {0x04, 0xE9, 0xE5, 0x00, 0x69, 0xEC}; 39 | 40 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 41 | 42 | void setup() 43 | { 44 | Serial.begin(115200); 45 | artnet.begin(mac, ip); 46 | leds.begin(); 47 | initTest(); 48 | Serial.println("Hello, ArtNet Node Starting..."); 49 | 50 | // this will be called for each packet received 51 | artnet.setArtDmxCallback(onDmxFrame); 52 | } 53 | 54 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 55 | 56 | void loop() 57 | { 58 | // we call the read function inside the loop 59 | artnet.read(); 60 | } 61 | 62 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 63 | 64 | void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data) 65 | { 66 | sendFrame = 1; 67 | // set brightness of the whole strip 68 | if (universe == 15) 69 | { 70 | leds.setBrightness(data[0]); 71 | leds.show(); 72 | } 73 | 74 | // Store which universe has got in 75 | if ((universe - startUniverse) < maxUniverses) 76 | universesReceived[universe - startUniverse] = 1; 77 | 78 | for (int i = 0 ; i < maxUniverses ; i++) 79 | { 80 | if (universesReceived[i] == 0) 81 | { 82 | Serial.println("Something is broken..."); 83 | sendFrame = 0; 84 | break; 85 | } 86 | } 87 | 88 | // read universe and put into the right part of the display buffer 89 | for (int i = 0; i < length / 3; i++) 90 | { 91 | int led = i + (universe - startUniverse) * (previousDataLength / 3); 92 | if (led < numLeds) 93 | leds.setPixelColor(led, data[i * 3], data[i * 3 + 1], data[i * 3 + 2]); 94 | } 95 | previousDataLength = length; 96 | 97 | if (sendFrame) 98 | { 99 | leds.show(); 100 | // Reset universeReceived to 0 101 | memset(universesReceived, 0, maxUniverses); 102 | } 103 | } 104 | 105 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 106 | 107 | void initTest() 108 | { 109 | for (int i = 0 ; i < numLeds ; i++) 110 | leds.setPixelColor(i, 127, 0, 0); 111 | leds.show(); 112 | delay(500); 113 | for (int i = 0 ; i < numLeds ; i++) 114 | leds.setPixelColor(i, 0, 127, 0); 115 | leds.show(); 116 | delay(500); 117 | for (int i = 0 ; i < numLeds ; i++) 118 | leds.setPixelColor(i, 0, 0, 127); 119 | leds.show(); 120 | delay(500); 121 | for (int i = 0 ; i < numLeds ; i++) 122 | leds.setPixelColor(i, 0, 0, 0); 123 | leds.show(); 124 | } 125 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Teensy-4.1-as-ArtNet-Node-for-5v-WS2812-LED 2 | 3 | Ever more efficient ways of realizing LED strips able to be controlled by a computer. The latest recipe uses a Teensy 4.1 to read ArtNet data from MadMapper to then drive a 5v RGB LED Strip. 4 | 5 | Read the full writeup, see pictures, video walthrough,a nd get all the 3D models on the full website: https://www.caseyjscalf.com/blog-full-roll/2022/3/21/teensy-41-as-artnet-node-for-5v-ws2812-led 6 | 7 | Code adapted from the example shipped with the Teensyduino. 8 | https://github.com/natcl/Artnet/blob/master/examples/NeoPixel/ArtnetNeoPixel/ArtnetNeoPixel.ino 9 | 10 | ![Casey J Scalf - Blog - Teensy 4 1 as ArtNet Node for 5v WS2812 LED - Banner Hero 1](https://user-images.githubusercontent.com/7865492/164351474-9580ece6-d9f1-470c-8c9a-712dba2cdd67.png) 11 | --------------------------------------------------------------------------------