Skip to content

Commit 6cc30d8

Browse files
tigoeTom Igoe
authored andcommitted
Updated TwitterClient example to fix timing bug
1 parent 15abca0 commit 6cc30d8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

examples/TwitterClient/TwitterClient.ino

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* Ethernet shield attached to pins 10, 11, 12, 13
1818
1919
created 21 May 2011
20+
updates 2 Mar 2012
2021
by Tom Igoe
2122
2223
This code is in the public domain.
@@ -29,18 +30,18 @@
2930
// Enter a MAC address and IP address for your controller below.
3031
// The IP address will be dependent on your local network:
3132
byte mac[] = {
32-
0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x01 };
33+
0xDE,0xAD,0xBE,0xEF,0xFE,0xED };
3334
IPAddress ip(192,168,1,20);
3435

3536
// initialize the library instance:
3637
EthernetClient client;
3738

38-
const int requestInterval = 60000; // delay between requests
39+
const unsigned long requestInterval = 60000; // delay between requests
3940

4041
char serverName[] = "api.twitter.com"; // twitter URL
4142

4243
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
4445

4546
String currentLine = ""; // string to hold the text from server
4647
String tweet = ""; // string to hold the tweet
@@ -54,10 +55,14 @@ void setup() {
5455
// initialize serial:
5556
Serial.begin(9600);
5657
// attempt a DHCP connection:
58+
Serial.println("Attempting to get an IP address using DHCP:");
5759
if (!Ethernet.begin(mac)) {
60+
Serial.println("failed to get an IP address using DHCP, trying manually");
5861
// if DHCP fails, start with a hard-coded address:
5962
Ethernet.begin(mac, ip);
6063
}
64+
Serial.print("My IP address:");
65+
Serial.println(ip);
6166
// connect to Twitter:
6267
connectToServer();
6368
}

0 commit comments

Comments
 (0)