Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Twitter Egg Detection System
- //Adam Robbins 2012
- //bobbinz.co.uk
- #include <Ethernet.h>
- #include <EthernetDHCP.h>
- #include <EthernetDNS.h>
- #include <Twitter.h>
- byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
- // Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
- Twitter twitter("<<< your token here >>>");
- // Message to post
- char msg[] = "An Egg just got laid :) #chickens #eggs";
- //Egg Detection System
- #define eggdetect 1 //change number to the pin number you are using
- void setup()
- {
- delay(1000);
- EthernetDHCP.begin(mac);
- Serial.begin(9600);
- }
- void loop()
- {
- if (eggdetect == 1)
- {
- Serial.println("connecting ...");
- if (twitter.post(msg)) {
- int status = twitter.wait();
- if (status == 200) {
- Serial.println("OK.");
- } else {
- Serial.print("failed : code ");
- Serial.println(status);
- }
- } else {
- Serial.println("connection failed.");
- }
- else if
- {
- EthernetDHCP.maintain();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement