NapsterMP3

Artnet to Fastled

Sep 16th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <Artnet.h>
  2. #include <Ethernet.h>
  3. #include <EthernetUdp.h>
  4. #include <SPI.h>
  5. #include <FastLED.h>
  6.  
  7. #define NUM_LEDS 170
  8. #define DATA_PIN 3
  9. CRGB leds[NUM_LEDS];
  10.  
  11. // Configurações
  12. byte ip[] = {192, 168, 0, 30};
  13. byte mac[] = {0x04, 0xE9, 0xE5, 0x00, 0x69, 0xEC};
  14. const int universo = 0;
  15.  
  16. Artnet artnet;
  17. void setup(){
  18.  
  19. FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
  20. artnet.begin(mac, ip);
  21. artnet.setArtDmxCallback(onDmxFrame);
  22. }
  23.  
  24. void loop()
  25. {
  26. artnet.read();
  27. }
  28.  
  29. void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
  30. {
  31. if (universe == universo){
  32. for (int i = 0; i < length; i+3)
  33. {
  34. leds[i].setRGB( data[i],data[i+1], data[i+2]);
  35. }
  36. }
  37. FastLED.show();
  38. }
Add Comment
Please, Sign In to add comment