bambangSud

send twitter from ethernet shield

Jul 1st, 2013
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. /* Post a simple message to Twitter */
  2. #if defined(ARDUINO) && ARDUINO > 18
  3. #include <SPI.h>
  4. #endif
  5. #include <Ethernet.h>
  6. //#include <EthernetDNS.h> // only for IDE 0022 or earlier
  7. #include <Twitter.h>
  8.  
  9. byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  10. byte ip[] = { 192,168,1, 177 };
  11. byte gateway[] = { 36,72,80,1 };
  12. byte subnet[] = { 255, 255, 0, 0 };
  13.  
  14. Twitter twitter("382956349-7b6otEoMTliErWGrbI2pxsiBX9Cz9RVrIOrfzuV1");
  15. char msg[] = "Hello test tweet";
  16.  
  17. void setup()
  18. {
  19. Ethernet.begin(mac, ip, gateway, subnet);
  20. Serial.begin(9600);
  21.  
  22. delay(1000);
  23.  
  24. Serial.println("connecting ...");
  25. if (twitter.post(msg)) {
  26. int status = twitter.wait(&Serial);
  27. if (status == 200) {
  28. Serial.println("OK.");
  29. } else {
  30. Serial.print("failed : code ");
  31. Serial.println(status);
  32. }
  33. } else {
  34. Serial.println("connection failed.");
  35. }
  36. }
  37.  
  38. void loop()
  39. {
  40. }
Advertisement
Add Comment
Please, Sign In to add comment