https://learn.sparkfun.com/tutorials/sp … led-shield
I’m not able to get my ESP32 to run a strip of 300 LEDs. I know how to set up the output in Resolume, but even when I have it spanning from universe 0-1 or even 0-3, it only recognizes the last one.
#include <WiFi.h>
#include <WiFiUDP.h>
#include <ArtnetWifi.h> //https://github.com/rstephan/ArtnetWifi
#include <FastLED.h>
// WiFi network name and password:
const char * ssid = "redacted";
const char * password = "redacted";
// Internet domain to request from:
const char * hostDomain = "example.com";
const int hostPort = 80;
const int BUTTON_PIN = 0;
const int LED_PIN = LED_BUILTIN;
// Artnet settings
ArtnetWifi artnet;
WiFiUDP UDPSend;
const int startUniverse = 0;
const int endUniverse = 2;//end Universe should be total channels/512
bool sendFrame = 1;
int previousDataLength = 0;
//Pin Definitions for ESP32 WROOM
#define CLOCK 5
#define DATA0 19
#define DATA1 18
#define DATA2 27
//Channel and Peripheral Definitions
#define NUM_LEDS 300
#define NUM_LED_CHANNELS NUM_LEDS * 3
CRGB leds[NUM_LEDS];
uint8_t hue = 0;
// connect to wifi – returns true if successful or false if not
boolean connectWifi(void)
{
int ledState = 0;
boolean state = true;
int i = 0;
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
Serial.println("Connecting to WiFi network: " + String(ssid));
while (WiFi.status() != WL_CONNECTED) {
// Blink LED while we're connecting:
digitalWrite(LED_PIN, ledState);
ledState = (ledState + 1) % 2; // Flip ledState
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 onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
{
// read universe and put into the right part of the display buffer
//DMX data should be sent with the first LED in the string on channel 0 of Universe 0
for (int channel = 0; channel < length; channel++)
{
if (channel < NUM_LED_CHANNELS && channel % 3 == 0) //Only write on every 3rd piece of data so we correctly parse things into our RGB array
{
leds[channel / 3] = CRGB(data[channel], data[channel + 1], data[channel + 2]);
}
}
previousDataLength = length;
if (universe == endUniverse) //Display our data if we have received all of our universes, prevents incomplete frames when more universes are concerned.
{
FastLED.show();
UDPSend.flush();
}
}
void setup()
{
Serial.begin(115200);
//Fixture Hardware Declarations
FastLED.addLeds<WS2813 , DATA0, RGB>(leds, NUM_LEDS);
if (connectWifi())
{
Serial.println("Connected to WiFi network: " + String(ssid));
}
artnet.begin();
artnet.setArtDmxCallback(onDmxFrame);
}
void loop()
{
artnet.read();
}