I have twitter updating the number with each button press. Right now it just tweets a number. How can I have a bit of text in front of the number? Something like. Button press 1, Button Press 2?
For the line:twitter.post(temp1);
I have tried things like twitter.post("Button press",temp1); like I would on an LCD but no luck here.
#include <SPI.h> // needed in Arduino 0019 or later
#include <Ethernet.h>
#include <Twitter.h>
// The includion of EthernetDNS is not needed in Arduino IDE 1.0 or later.
// Please uncomment below in Arduino IDE 0022 or earlier.
//#include <EthernetDNS.h>
const int buttonPin = 9; // the pushbutton pin
//int buttonState = 0; // previous state of the button
// Variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
// Ethernet Shield Settings
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// If you don't specify the IP address, DHCP is used(only in Arduino 1.0 or later).
//byte ip[] = { 192, 168, 1, 195 };
// Your Token to Tweet (get it from
http://arduino-tweet.appspot.com/)
Twitter twitter("my token");
int temp2;
void setup()
{
delay(1000);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
//Ethernet.begin(mac, ip);
// or you can use DHCP for autoomatic IP address configuration.
Ethernet.begin(mac);
Serial.begin(9600);
Serial.println("connecting ...");
}
void loop()
{
int j=0;
char temp1[7];
buttonState = digitalRead(buttonPin);
if (buttonState != lastButtonState)
{
if (buttonState == HIGH)
{
buttonPushCounter++;
}
itoa (buttonPushCounter,temp1,10);
twitter.post(temp1); //This is where is the number is tweeted
// 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.");
}
//delay(100);
lastButtonState = buttonState;
}