Moderators: adafruit_support_bill, adafruit
// necessary libraries
#if defined(ARDUINO) && ARDUINO > 18 // If using Arduino 0019 or later, include SPI.h
#include <SPI.h>
#endif
#include <Ethernet.h>
#include <EthernetDNS.h>
#include <Twitter.h>
// our event messages
char b1[]="one";
char b2[]="two";
char b3[]="three";
char b4[]="four";
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // create MAC address for ethernet shield
byte ip[] = { }; // choose your own IP for ethernet shield
byte gateway[] = { }; // your network gateway
byte subnet[] = { 255, 255, 255, 0 }; // your network subnet
// Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
Twitter twitter("aaaaaaaa");
// replace aaaaaaa with your token
// ***********************************************************************************************
void setup()
{
delay(5000);
Ethernet.begin(mac, ip, gateway, subnet);
Serial.begin(9600);
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
}
void tweet(char msg[])
{
Serial.println("connecting ...");
if (twitter.post(msg)) {
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()
{
if (digitalRead(2)==HIGH)
{
tweet(b1);
delay(2000);
}
if (digitalRead(3)==HIGH)
{
tweet(b2);
delay(2000);
}
if (digitalRead(4)==HIGH)
{
tweet(b3);
delay(2000);
}
if (digitalRead(5)==HIGH)
{
tweet(b4);
delay(2000);
}
}the pins are set high
i wish to use basic relays to switch the inputs 2,3,4,5
Return to General Project help
Users browsing this forum: Google [Bot], huatian and 5 guests