Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated TwitterClient example to fix timing bug

  • Loading branch information...
commit 366a4909738b341d871142975e5789e5ced63ff0 1 parent 3f7ce2e
Tom Igoe authored
11 libraries/Ethernet/examples/TwitterClient/TwitterClient.ino
@@ -17,6 +17,7 @@
17 17 * Ethernet shield attached to pins 10, 11, 12, 13
18 18
19 19 created 21 May 2011
  20 + updates 2 Mar 2012
20 21 by Tom Igoe
21 22
22 23 This code is in the public domain.
@@ -29,18 +30,18 @@
29 30 // Enter a MAC address and IP address for your controller below.
30 31 // The IP address will be dependent on your local network:
31 32 byte mac[] = {
32   - 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x01 };
  33 + 0xDE,0xAD,0xBE,0xEF,0xFE,0xED };
33 34 IPAddress ip(192,168,1,20);
34 35
35 36 // initialize the library instance:
36 37 EthernetClient client;
37 38
38   -const int requestInterval = 60000; // delay between requests
  39 +const unsigned long requestInterval = 60000; // delay between requests
39 40
40 41 char serverName[] = "api.twitter.com"; // twitter URL
41 42
42 43 boolean requested; // whether you've made a request since connecting
43   -long lastAttemptTime = 0; // last time you connected to the server, in milliseconds
  44 +unsigned long lastAttemptTime = 0; // last time you connected to the server, in milliseconds
44 45
45 46 String currentLine = ""; // string to hold the text from server
46 47 String tweet = ""; // string to hold the tweet
@@ -54,10 +55,14 @@ void setup() {
54 55 // initialize serial:
55 56 Serial.begin(9600);
56 57 // attempt a DHCP connection:
  58 + Serial.println("Attempting to get an IP address using DHCP:");
57 59 if (!Ethernet.begin(mac)) {
  60 + Serial.println("failed to get an IP address using DHCP, trying manually");
58 61 // if DHCP fails, start with a hard-coded address:
59 62 Ethernet.begin(mac, ip);
60 63 }
  64 + Serial.print("My IP address:");
  65 + Serial.println(ip);
61 66 // connect to Twitter:
62 67 connectToServer();
63 68 }

0 comments on commit 366a490

Please sign in to comment.
Something went wrong with that request. Please try again.