Skip to content

Instantly share code, notes, and snippets.

@ArduinoDiscordBot
Created November 25, 2020 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArduinoDiscordBot/f9623dcbd3bdcdd49699277af3d62020 to your computer and use it in GitHub Desktop.
Save ArduinoDiscordBot/f9623dcbd3bdcdd49699277af3d62020 to your computer and use it in GitHub Desktop.
Code by Nick116#3055 - Wed Nov 25 2020 19:14:47 GMT+0000 (Coordinated Universal Time)

This gist was pasted by the Arduino discord server bot.

This gist was automatically pasted at the request of the code author or one of the discord server helpers. If you have any suggestions or bugs to report, you can do so on our GitHub repository, or in our discord server. This project is run by volunteers so feel free to fork and commit your changes then open a pull request!


⬇️ Pasted Code ⬇️

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <ArtnetWifi.h>
#include <FastLED.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>
// LED Strip
const int numLeds = 120; // Change if your setup has more or less LED's
const int numberOfChannels = numLeds * 3; // Total number of DMX channels you want to receive (1 led = 3 channels)
#define DATA_PIN 16 //The data pin that the WS2812 strips are connected to.
CRGB leds[numLeds];
//Initialize WifiManager Library
WiFiManager wifiManager;
// Artnet settings
ArtnetWifi artnet;
const int startUniverse = 0;
bool sendFrame = 1;
int previousDataLength = 0;
// connect to wifi – returns true if successful or false if not
boolean ConnectWifi(void)
{
wifiManager.autoConnect("AP-NAME");
Serial.println("");
Serial.println("Connecting to WiFi");
// Wait for connection
}
void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
{
sendFrame = 1;
// set brightness of the whole strip
if (universe == 15)
{
FastLED.setBrightness(data[0]);
}
// read universe and put into the right part of the display buffer
for (int i = 0; i < length / 3; i++)
{
int led = i + (universe - startUniverse) * (previousDataLength / 3);
if (led < numLeds)
{
leds[led] = CRGB(data[i * 3], data[i * 3 + 1], data[i * 3 + 2]);
}
}
previousDataLength = length;
FastLED.show();
}
void setup()
{
Serial.begin(115200);
ConnectWifi();
Serial.println("Connected!");
artnet.begin();
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, numLeds);
// onDmxFrame will execute every time a packet is received by the ESP32
artnet.setArtDmxCallback(onDmxFrame);
}
void loop()
{
// we call the read function inside the loop
artnet.read();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment