Skip to content

Instantly share code, notes, and snippets.

@tbraun89
Last active December 14, 2015 19:08
Show Gist options
  • Save tbraun89/5134108 to your computer and use it in GitHub Desktop.
Save tbraun89/5134108 to your computer and use it in GitHub Desktop.
Demonstration: This code hangs on all arduino versions after some time...
#include <SPI.h>
#include <Ethernet.h>
#define GREEN_PIN 41
byte mac[] = { ... };
// google.de
IPAddress server(173, 194, 69, 94);
int port = 80;
EthernetClient client;
boolean ethernetAvailable;
char testCharacter = ' ';
void setup() {
Ethernet.begin(mac);
pinMode(GREEN_PIN, OUTPUT);
digitalWrite(GREEN_PIN, HIGH);
delay(1000);
}
void loop() {
if (client.connected()) {
if (client.available()) {
char c = client.read();
testCharacter += c;
} // no else
digitalWrite(GREEN_PIN, LOW);
} else {
client.stop();
digitalWrite(GREEN_PIN, HIGH);
delay(1000);
if (client.connect(server, port)) {
client.println("GET / HTTP/1.0");
client.println();
} // no else
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment