diff --git a/README.md b/README.md index f88b230..971f927 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,52 @@ void loop() } ``` + +### Artnet Receiver + FastLED + + +``` C++ +#include + +// declarations for Ethernet/WiFi + +ArtnetReceiver artnet; + +// FastLED +#define NUM_LEDS 1 +CRGB leds[NUM_LEDS]; +const uint8_t PIN_LED_DATA = 3; + +void setup() +{ + // setup Ethernet/WiFi... + + // setup FastLED + FastLED.addLeds(&leds, NUM_LEDS); + + artnet.begin(); + artnet.subscribe(universe, [](uint8_t* data, uint16_t size) + { + // artnet data size per packet is 512 max + // so there is max 170 pixel per packet (per universe) + for (size_t pixel = 0; pixel < NUM_LEDS; ++pixel) + { + size_t idx = pixel * 3; + leds[pixel].r = data[idx + 0]; + leds[pixel].g = data[idx + 1]; + leds[pixel].b = data[idx + 2]; + } + FastLED.show(); + }); +} + +void loop() +{ + artnet.parse(); // check if artnet packet has come and execute callback +} +``` + + ## Other Settings ### Net, Sub-Net, Universe, and Universe(15bit)