Skip to content

Instantly share code, notes, and snippets.

@mrrees
Created July 25, 2017 05:12
Show Gist options
  • Save mrrees/c02fe745de616f17c6cf79790d27e022 to your computer and use it in GitHub Desktop.
Save mrrees/c02fe745de616f17c6cf79790d27e022 to your computer and use it in GitHub Desktop.
/*
* Ethernet_FastLED.ino - Simple sketch to listen for E1.31 data on an
* UNO Ethernet shield and drive WS2811 LEDs.
*
* == Requires FastLED - http://github.com/FastLED/FastLED
*
* Project: E131 - E.131 (sACN) library for Arduino
* Copyright (c) 2015 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
* subject to the laws and regulations where you are using it. Due diligence
* is strongly suggested before using this code. Please give credit where due.
*
* The Author makes no warranty of any kind, express or implied, with regard
* to this program or the documentation contained in this document. The
* Author shall not be liable in any event for incidental or consequential
* damages in connection with, or arising out of, the furnishing, performance
* or use of these programs.
*
*/
#include <SPI.h>
#include <Ethernet.h>
#include <E131.h>
#include <FastLED.h>
#define NUM_LEDS_PER_STRIP 170
// Note: this can be 12 if you're using a teensy 3 and don't mind soldering the pads on the back
#define NUM_STRIPS 8
// Note: this can be 12 if you're using a teensy 3 and don't mind soldering the pads on the back
byte mac[] = { 0xDE, 0xAD, 0xBE, 0x2F, 0x1E, 0xE3 };
E131 e131;
CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];
// Pin layouts on the teensy 3/3.1:
// WS2811_PORTD: 2,14,7,8,6,20,21,5
// WS2811_PORTC: 15,22,23,9,10,13,11,12,28,27,29,30 (these last 4 are pads on the bottom of the teensy)
// WS2811_PORTDC: 2,14,7,8,6,20,21,5,15,22,23,9,10,13,11,12 - 16 way parallel
//
// Pin layouts on the due
// WS2811_PORTA: 69,68,61,60,59,100,58,31 (note: pin 100 only available on the digix)
// WS2811_PORTB: 90,91,92,93,94,95,96,97 (note: only available on the digix)
// WS2811_PORTD: 25,26,27,28,14,15,29,11
//
void setup() {
LEDS.addLeds<WS2811_PORTD,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP);
LEDS.setBrightness(32);
pinMode(9, OUTPUT);
digitalWrite(9, LOW); // reset the WIZ820io
delay(10);
digitalWrite(9, HIGH); // reset the WIZ820io
//pinMode(10, OUTPUT);
// digitalWrite(10, HIGH); // de-select WIZ820io
//pinMode(4, OUTPUT);
//digitalWrite(4, HIGH); // de-select the SD Card
Serial.begin(115200);
delay(10);
//SET IP BY STATIC ADDRESS
e131.begin(mac);
IPAddress ip(192,168,2,177);
IPAddress gateway(192,168,2,1);
IPAddress subnet_mask(255,255,255,0);
delay(2000);
//Verify IP in Serial prompt
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
void loop() {
/* Parse a packet and update pixels */
uint16_t r,g,b;
if(e131.parsePacket())
//Serial.println(e131.data[10]);
r = e131.data[0];
g = e131.data[1];
b = e131.data[2];
for(int i = 0; i < NUM_STRIPS; i++) {
for(int j = 0; j < NUM_LEDS_PER_STRIP; j++) {
r = e131.data[j*3];
g = e131.data[j*3 + 1];
b = e131.data[j*3 + 2];
leds[(i*NUM_LEDS_PER_STRIP) + j] = CRGB(r,g,b);
}
}
LEDS.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment