Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <Ethernet.h>
- #include <ArtNet.h>
- #include "FastLED.h"
- #define NUM_LEDS 50
- // Data pin that led data will be written out over
- #define DATA_PIN 5
- // This is an array of leds. One item for each led in your strip.
- CRGB leds[NUM_LEDS];
- // Default Configuration
- ArtNetConfig config = {
- {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}, // MAC
- {192, 168, 1, 177}, // IP
- {255, 255, 255, 0}, // Subnet mask
- 0x1936, // UDP port
- false, // DHCP
- 0, 0, // Net and subnet
- "OpenPixelNode", // Short name
- "Billy's Test Node v4", // Long name
- 1, // Number of ports
- {ARTNET_TYPE_DMX|ARTNET_TYPE_OUTPUT}, // Port types
- {0}, // Input port addresses
- {0} // Output port addresses
- };
- // Defaults
- byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
- IPAddress ip(192,168,1,177);
- // ArtNet class instance
- ArtNet artnet = ArtNet(config, 530);
- void setup() {
- //SPI.setClockDivider(SPI_CLOCK_DIV2);
- // Initialize Ethernet shield
- Ethernet.begin(mac, ip);
- uint16_t sizes[4] = {8192,0,0,0}; // 8 Kb memory to the first socket
- W5100.setRXMemorySizes(sizes);
- W5100.setTXMemorySizes(sizes);
- FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS);
- // Initialize ArtNet handler
- artnet.begin(); // Start ArtNet handling
- }
- void loop() {
- // Receive ArtNet package from Ethernet shield
- if(artnet.parsePacket()) {
- // Read and handle packet
- artnet.handleAny();
- // Check packet type
- if(artnet.getOpCode() == ARTNET_OPCODE_DMX) {
- // Get header and dmx data
- byte* dmx = artnet.getDmxData();
- byte port = artnet.getDmxPort();
- int dmx_length = artnet.getDmxLength();
- // Do your DMX handling here!!
- memcpy((CRGB*)leds, dmx, dmx_length / 3);
- FastLED.show();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment