Advertisement
bobbinz

Egg Detection

Jan 23rd, 2012
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Twitter Egg Detection System
  2. //Adam Robbins 2012
  3. //bobbinz.co.uk
  4.  
  5. #include <Ethernet.h>
  6. #include <EthernetDHCP.h>
  7. #include <EthernetDNS.h>
  8. #include <Twitter.h>
  9.  
  10. byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  11.  
  12. // Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
  13. Twitter twitter("<<< your token here >>>");
  14.  
  15. // Message to post
  16. char msg[] = "An Egg just got laid :) #chickens #eggs";
  17.  
  18. //Egg Detection System
  19. #define eggdetect 1 //change number to the pin number you are using
  20.  
  21. void setup()
  22. {
  23.   delay(1000);
  24.   EthernetDHCP.begin(mac);
  25.   Serial.begin(9600);
  26.  }
  27.  
  28. void loop()
  29. {  
  30.   if (eggdetect == 1)
  31.   {
  32.     Serial.println("connecting ...");
  33.     if (twitter.post(msg)) {
  34.       int status = twitter.wait();
  35.       if (status == 200) {
  36.         Serial.println("OK.");
  37.       } else {
  38.         Serial.print("failed : code ");
  39.         Serial.println(status);
  40.       }
  41.     } else {
  42.       Serial.println("connection failed.");
  43.     }
  44.     else if
  45.     {
  46.       EthernetDHCP.maintain();
  47.     }      
  48.   }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement