so i've just started with programming for arduino and since i've got a course in school where we are supposed to come up with a new product, i've started with the arduino because it seems to be the easiest way to build something new!
i'm in a group of real slackers and the only person who is currently working on this project is me, so my knowledge in coding is all we have...
what my project is supposed to do is to send me a tweet when a button is pressed (wireless doorbell and i've managed to get all the circuitry right, but it seems like i've failed with the coding.)
here's the code im currently using:
#include <SPI.h>
#include <Ethernet.h>
#include <Twitter.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x4F, 0x0D };
byte ip[] = { 192, 168, 0, 25 };
Twitter twitter("861799520-MhjIWEzWHz02OqvI8u5rByj83Js4OjpAcDpjR2g");
char msg[] = "you pressed the button!";
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13;
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop(){
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
Ethernet.begin(mac, ip);
Serial.begin(9600);
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.");
}
}
}
this is how it's all wired Imgur: The magic of the Internet (only temporarily)
what i want to know is, what am i doing wrong? since i have added the switch today, and tested so the button works by hooking up an LED to the wires (which originally were hooked up to a speaker since it's a wireless doorbell), im pretty sure the fault is in the code or to be more exact the part of the code which connects to the internet.
im going to check if the arduino gets the signal from the two wires (because that can be one problem) and does anyone know if i've made any mistakes regarding the code, because im almost a total noob when it comes to coding.
sources of some of the code:
the part which sends the tweet: http://arduino-tweet.appspot.com/