Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <Ethernet.h>
- #include <Twitter.h>
- byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // create MAC address for ethernet shield
- // Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
- Twitter twitter("14205607-aX34ti1eLI44r3dZpo2GtsI8YXf24M0sZSV7Taaaa");
- int analogZero;
- char tweetText[140];
- void setup()
- {
- delay(5000);
- Ethernet.begin(mac);
- Serial.begin(9600);
- }
- void tweet(char msg[])
- {
- Serial.println("connecting ...");
- if (twitter.post(msg))
- {
- // Specify &Serial to output received response to Serial.
- // If no output is required, you can just omit the argument, e.g.
- // int status = twitter.wait();
- int status = twitter.wait(&Serial);
- if (status == 200)
- {
- Serial.println("OK.");
- }
- else
- {
- Serial.print("failed : code ");
- Serial.println(status);
- }
- }
- else
- {
- Serial.println("connection failed.");
- }
- }
- void loop()
- {
- // get some data from A0.
- analogZero=analogRead(0);
- // assemble message to send. This inserts the value of "analogZero" into the variable "tweetText" at point %d
- sprintf(tweetText, "Prueba Arduino, Pin Analog 0 tiene el valor: %d. ", analogZero); //
- delay(1000);
- tweet(tweetText);
- do{ }
- while(1>0); // endless loop
- delay(61000)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement