Created
September 23, 2011 00:53
-
-
Save stilldavid/1236490 to your computer and use it in GitHub Desktop.
This file contains 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 <Ethernet.h> | |
#include <SPI.h> | |
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; | |
byte ip[] = { 192, 168, 20, 239 }; | |
byte server[] = { 10, 10, 10, 2 }; // Google | |
Client client(server, 8001); | |
void setup() | |
{ | |
Ethernet.begin(mac, ip); | |
Serial.begin(9600); | |
pinMode(4, OUTPUT); | |
digitalWrite(4, HIGH); | |
delay(1000); | |
Serial.println("connecting..."); | |
if (client.connect()) { | |
Serial.println("connected"); | |
client.println("[\"mayhem\"]\r"); | |
} else { | |
Serial.println("connection failed"); | |
} | |
} | |
void loop() { | |
if (client.available()) { | |
char c = client.read(); | |
Serial.print(c); | |
client.flush(); | |
digitalWrite(4, LOW); | |
delay(1000); | |
digitalWrite(4, HIGH); | |
} | |
if (!client.connected()) { | |
Serial.println(); | |
Serial.println("disconnecting."); | |
client.stop(); | |
delay(5000); | |
setup(); | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment