Go Down

Topic: help with alarm code (Read 4 times) previous topic - next topic

copachino

hi all...

i just foun this code but maybe im not editing it right....

what i want with the code its ust to simple post a tweet every time my led turns high....

but have many troubles, for example the code just post when i open serial monitor, second when i change the code for the led input, then it doesnt post anything,
and last, its that twitter does not acept my msg cos it said its the same tweet, so how can i change that

Code: [Select]
#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 ledPin = 3;
int ledState = LOW;

// 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("1220261654-BPUYlMFTyfs5ooSFSA62C57Ujeqnr9hdn7PARZm");

// Message to post


void setup()
{
 
  pinMode(ledPin, INPUT);
  delay(1000);
  Ethernet.begin(mac);
  // or you can use DHCP for autoomatic IP address configuration.
  // Ethernet.begin(mac);
  Serial.begin(9600);
 
  Serial.println("connecting ...");
 
}

void loop()
{
 
  Serial.println(ledState);
  char msg[]="que odes";
  if (ledState == HIGH)
  {
 
  int cont=0;
  delay(1000);
  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.");
   
   
  }
  }
}

Nick Gammon

Code: [Select]

  if (ledState == HIGH)
    ...


Your code never reads or changes ledState.

copachino

so if i attacht it to an interrupt and read the rising, the arduino will know that, i see that error, thanks, but how can i change that arduino knwos that state and post the msg without open the serial monitor???

Frisky

Where is the attacthinterrupt at I see nothing for setting up or handling an external interrupt.

copachino

i still have no posted the changes that NIck suggested....



Go Up