Arduino Code
#include <SPI.h> // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008
#include <Adafruit_NeoPixel.h>
#define UDP_TX_PACKET_MAX_SIZE 400
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEC
};
IPAddress ip(192, 168, 1, 177);
unsigned int localPort = 88; // local port to listen on
// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char ReplyBuffer[] = "acknowledged"; // a string to send back
// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;
int numLEDs = 120;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(numLEDs, 6, NEO_GRB + NEO_KHZ800); //pin 6
void setup() {
// start the Ethernet and UDP:
Ethernet.begin(mac, ip);
Udp.begin(localPort);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
// if there's data available, read a packet
PORTD |= 1<<2;
int packetSize = Udp.parsePacket();
PORTD &= !(1<<2);
if (packetSize) {
PORTD |= 1<<3;
// read the packet into packetBufffer
Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
int i = 0;
int idx = 0;
PORTD &= !(1<<3);
PORTD |= 1<<4;
do{
idx = 3 * i;
strip.setPixelColor(i, packetBuffer[idx], packetBuffer[idx+1], packetBuffer[idx+2]); //nummer, r, g, b
i++;
} while (i < numLEDs);
PORTD &= !(1<<4);
PORTD |= 1<<5;
strip.show();
PORTD &= !(1<<5);
}
//delay(1);
}
VB Code
Dim myUdpSender As New UdpClient(0) Private Sub init() Dim IPAd As String = "192.168.178.177" myUdpSender.Connect(IPAd, 88) REM Destination IP and Port End Sub Private Sub send() myUdpSender.Send(myArray, myArrayLength) End Sub
Timing
