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.
2930// Enter a MAC address and IP address for your controller below.
3031// The IP address will be dependent on your local network:
3132byte mac[] = {
32- 0x00 , 0xAA , 0xBB , 0xCC , 0xDE , 0x01 };
33+ 0xDE , 0xAD , 0xBE , 0xEF , 0xFE , 0xED };
3334IPAddress ip (192 ,168 ,1 ,20 );
3435
3536// initialize the library instance:
3637EthernetClient client;
3738
38- const int requestInterval = 60000 ; // delay between requests
39+ const unsigned long requestInterval = 60000 ; // delay between requests
3940
4041char serverName[] = " api.twitter.com" ; // twitter URL
4142
4243boolean 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
4546String currentLine = " " ; // string to hold the text from server
4647String 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