diff options
author | Cristian Maglie <c.maglie@bug.st> | 2012-05-21 01:56:06 +0200 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2012-05-22 11:23:47 +0200 |
commit | 3786e337e0211ca1ef94b37b03e891adfb3b5f9a (patch) | |
tree | dd7f8f6fd396243460ec22da89bfbd71d552f484 /libraries/Ethernet/examples/TwitterClient/TwitterClient.ino | |
parent | 324023a67afd1691f12ead4388d7cdf1a9d1a6ef (diff) | |
parent | 9a8976ce56bcdb70815dd58c1764d9e5c3b6fe95 (diff) |
Pre-merge upstream Arduino
Diffstat (limited to 'libraries/Ethernet/examples/TwitterClient/TwitterClient.ino')
-rw-r--r-- | libraries/Ethernet/examples/TwitterClient/TwitterClient.ino | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino b/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino index f113e17..a3b397d 100644 --- a/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino +++ b/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino @@ -14,7 +14,7 @@ version 0019. Circuit: - * Ethernet shield attached to pins 10, 11, 12, 13 + * Ethernet shield attached to pins 10, 11, 12, 13 created 21 May 2011 by Tom Igoe @@ -35,12 +35,12 @@ IPAddress ip(192,168,1,20); // initialize the library instance: EthernetClient client; -const int requestInterval = 60000; // delay between requests +const unsigned long requestInterval = 60000; // delay between requests char serverName[] = "api.twitter.com"; // twitter URL boolean requested; // whether you've made a request since connecting -long lastAttemptTime = 0; // last time you connected to the server, in milliseconds +unsigned long lastAttemptTime = 0; // last time you connected to the server, in milliseconds String currentLine = ""; // string to hold the text from server String tweet = ""; // string to hold the tweet @@ -51,13 +51,17 @@ void setup() { currentLine.reserve(256); tweet.reserve(150); -// initialize serial: + // initialize serial: Serial.begin(9600); // attempt a DHCP connection: + Serial.println("Attempting to get an IP address using DHCP:"); if (!Ethernet.begin(mac)) { // if DHCP fails, start with a hard-coded address: + Serial.println("failed to get an IP address using DHCP, trying manually"); Ethernet.begin(mac, ip); } + Serial.print("My address:"); + Serial.println(Ethernet.localIP()); // connect to Twitter: connectToServer(); } @@ -114,7 +118,7 @@ void connectToServer() { Serial.println("connecting to server..."); if (client.connect(serverName, 80)) { Serial.println("making HTTP request..."); - // make HTTP GET request to twitter: + // make HTTP GET request to twitter: client.println("GET /1/statuses/user_timeline.xml?screen_name=arduino&count=1 HTTP/1.1"); client.println("HOST: api.twitter.com"); client.println(); @@ -122,3 +126,4 @@ void connectToServer() { // note the time of this connect attempt: lastAttemptTime = millis(); } + |