Good day,
I need help with an Arduino sketch. I got the sketch from a source but would like to add a button function to it. For example when button is pressed, then ( sketch is carried out). Been trying for days now but cannot seem to get it to work, my sketch without the button function is shown bellow
#include <SPI.h> // needed in Arduino 0019 or later
#include <Ethernet.h>
#include <Twitter.h>
// The inclusion of EthernetDNS is not needed in Arduino IDE 1.0 or later.
// Please uncomment below in Arduino IDE 0022 or earlier.
//#include <EthernetDNS.h>
// 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, 2, 250 };
// Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
Twitter twitter("xxxxx");
// Message to post
char msg[140];
int delayS = 60;
void softReset()
{
asm volatile ("jmp 0");
}
void setup()
{
Ethernet.begin(mac);
Serial.begin(9600);
}
void loop()
{
snprintf(msg, 140, "Hello World![%d]", analogRead(A0));
Serial.println("Delaying ...");
for(int i = 0; i < delayS; i++)
{
delay(1000);
Serial.print(i);
Serial.print(" ");
}
Serial.println();
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.");
}
softReset();
}
can someone help with this? your help is much appreciated =)