Created
November 17, 2012 13:47
-
-
Save spinogrizz/4096090 to your computer and use it in GitHub Desktop.
Blink LED on every UDP packet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include <Ethernet.h> | |
#include <EthernetUdp.h> | |
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; | |
IPAddress ip(192, 168, 0, 177); | |
unsigned int localPort = 8888; | |
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; | |
EthernetUDP Udp; | |
void setup() { | |
// start the Ethernet and UDP: | |
Ethernet.begin(mac,ip); | |
Udp.begin(localPort); | |
Serial.begin(9600); | |
pinMode(7, OUTPUT); | |
} | |
void loop() { | |
int bytesAvailable = Udp.parsePacket(); | |
if( bytesAvailable ) | |
{ | |
digitalWrite(7, HIGH); | |
delay(100); | |
digitalWrite(7, LOW); | |
Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE); | |
} | |
delay(10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment