Show Posts
|
|
Pages: 1 [2] 3 4 ... 23
|
|
16
|
Using Arduino / Programming Questions / Re: help with alarm code
|
on: March 14, 2013, 02:41:48 pm
|
yes now the main problem its the pointer #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> int count; 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("YOUR-TOKEN-HERE");
// Message to post char msg; char str1[]="post one"; char str2[]="post two"; char str3[]="post three"; char str4[]="post four"; char str5[]="post five"; char str6[]="post six";
void setup() { digitalWrite(2, HIGH); attachInterrupt(0, alarm, RISING); delay(1000); Ethernet.begin(mac); // or you can use DHCP for autoomatic IP address configuration. // Ethernet.begin(mac); Serial.begin(9600); }
void loop()
{ if (LedState == HIGH) { LedState==LOW; switch (count) { case 1: *msg =& str1; count++; break; case 2: msg =& str2; count++; break; case 3: msg =& str3; count++; break; case 4: msg =& str4; count++; break; case 5: msg =& str5; count++; break; case 6: msg =& str6; count=0; break; } } 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."); }
}
void alarm() { LedState = HIGH; }
|
|
|
|
|
18
|
Using Arduino / Programming Questions / Re: help with alarm code
|
on: March 14, 2013, 02:24:04 pm
|
y see that mistake sorry if i didnt see it..... and if i just call msg as an char pointer and not an array???? like char *msg; still the compiler says im wrong in the if funtion #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>
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("YOUR-TOKEN-HERE");
// Message to post char* msg[26]; char str1[]="post one"; char str2[]="post two"; char str3[]="post three"; char str4[]="post four"; char str5[]="post five"; char str6[]="post six";
void setup() { digitalWrite(2, HIGH); attachInterrupt(0, alarm, RISING); delay(1000); Ethernet.begin(mac); // or you can use DHCP for autoomatic IP address configuration. // Ethernet.begin(mac); Serial.begin(9600); }
void loop()
if (ledState == HIGH) { LedState==LOW; Swtich (count) { case 1: msg =& str1; count++; break case 2: msg =& str2; count++; break case 3: msg =& str3; count++; break case 4: msg =& str4; count++; break case 5: msg =& str5; count++; break case 6: msg =& str6; count=0; break; } } 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."); }
void alarm() { ledState = HIGH; }
|
|
|
|
|
19
|
Using Arduino / Programming Questions / Re: help with alarm code
|
on: March 14, 2013, 01:47:54 pm
|
ok, i have made some crrections but, still IDE says expected initializer before 'if' [quote] [#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>
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("YOUR-TOKEN-HERE");
// Message to post char* msg[26]; char str1[]="post one"; char str2[]="post two"; char str3[]="post three"; char str4[]="post four"; char str5[]="post five"; char str6[]="post six";
void setup() { digitalWrite(2, HIGH); attachInterrupt(0, alarm, RISING); delay(1000); Ethernet.begin(mac); // or you can use DHCP for autoomatic IP address configuration. // Ethernet.begin(mac); Serial.begin(9600);
void loop()
if (ledState == HIGH) { LedState==LOW; Swtich (count) { case 1: msg =& str1; count++; break case 2: msg =& str2; count++; break case 3: msg =& str3; count++; break case 4: msg =& str4; count++; break case 5: msg =& str5; count++; break case 6: msg =& str6; count=0; break; } } 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."); }
void alarm() { ledState = HIGH; }
|
|
|
|
|
21
|
Using Arduino / Programming Questions / Re: help with alarm code
|
on: March 14, 2013, 10:21:55 am
|
i used that because IDE told that that if i use char* msg[]; then the zise its unknown, still the error says that i need an initializer before if functions.... also doesnot allow me to use the normal { on the start of the void loop()..... so im not sure where its my mistake... maybe i have many of then
|
|
|
|
|
22
|
Using Arduino / Programming Questions / Re: help with alarm code
|
on: March 14, 2013, 08:57:04 am
|
this is my code but i doesnt compile, i cant find the error... #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>
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("YOUR-TOKEN-HERE");
// Message to post char* msg[20]; char str1[]="post one"; char str2[]="post two"; char str3[]="post three"; char str4[]="post four"; char str5[]="post five"; char str6[]="post six";
void setup() { digitalWrite(2, HIGH); attachInterrupt(0, alarm, RISING); delay(1000); Ethernet.begin(mac); // or you can use DHCP for autoomatic IP address configuration. // Ethernet.begin(mac); Serial.begin(9600);
void loop()
int count=0; if (ledState == HIGH) { LedState==LOW; Swtich (count) { case 1: msg =& str1; count++; break case 2: msg =& str2; count++; break case 3: msg =& str3; count++; break case 4: msg =& str4; count++; break case 5: msg =& str5; count++; break case 6: msg =& str6; count=0; break; } } 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."); }
}
void alarm() { ledState = HIGH; }
|
|
|
|
|
23
|
Using Arduino / Programming Questions / Re: help with alarm code
|
on: March 13, 2013, 07:48:53 am
|
i dont need the serial monitor, but, the problem its that until i dont open the serial monitor arduino wont post anything.... and sorry for my ignorance, but why would i need a debounce?? i just need to recognize the change of state on the pin, so if it bounce, until only post one msg its ok for me.... and for the twitter error for posting the same msg i think that using a counter and 5 different msgs in a switch sentence, and the variable char msg[] should be declared as a pointer... do u think this make any logic???, if so later this day i will post a program to do that... also thanks for your help it really helps me a lot
|
|
|
|
|
24
|
Using Arduino / Programming Questions / Re: help with alarm code
|
on: March 12, 2013, 08:35:35 am
|
|
thanks everyone for the help, i will try more a little late.
And for the variable char msg.... the lib of this code has tobe declared as char.... maybe i can post millis()... but i will have to study that
|
|
|
|
|
25
|
Using Arduino / Programming Questions / Re: help with alarm code
|
on: March 12, 2013, 07:21:47 am
|
Try this out there is no debounce of the pin Interrupt 0 is digital pin 2 on the Uno baord #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"); // you shouldn't post your token we could post on your Twitter account with this info...
// Message to post
void setup() { digitalWrite(2, HIGH); //turn on internall pullup resistor attachInterrupt(0, ExtInt0Fall, FALLING); // there is no debouce of this pin delay(1000); Ethernet.begin(mac); // or you can use DHCP for autoomatic IP address configuration. // Ethernet.begin(mac); Serial.begin(9600); Serial.println("connecting ..."); char msg[]="que odes"; }
void loop() { if (ledState == HIGH) { ledState = LOW;//[color=red]this turns the led off???[/color] int cont=0; // ? what is this for??//[color=red]this was meant tobe a counter to print it with the msg so the msg could change and twitter did not give error[/color] Serial.println("High now"); 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."); } }
void ExtInt0Fall() { ledState = HIGH; }
the problem im still trapped its that still the code post only when i open the serial monitor in the IDE, only that this time it waits untill the led turns on.... but its possible to change that i don need to open the serial port???... i dont need any status msg on serial monitor, i mean the arduino will never be connected to a computer to run this program.....
|
|
|
|
|
27
|
International / Español / arduino twitter alarma
|
on: March 11, 2013, 02:27:49 pm
|
Buenas a todos y bueno sigo trasteando el ethernet shield y encontre como hacer post con el twitter que me parecio muy interesante, el problema es que quiero que el arduino haga un tweet cada vez que un pin cambie de estado LOW a HIGH, ahora el problema es que el programa que encontre aqui publica un tweet cada vez que abro el puerto serial mendiante el IDE de arduino, por lo cual en mi muy basica experiencia no he logrado cambiarlo, lo segundo es que twitter no me deja hacer el mismo tweet 2 veces por lo que reconoce es un mensaje duplicado, alguien que tenga experiencia en esto que me puead dar un pequeño empujon?? el codigo que uso es el basico #if defined(ARDUINO) && ARDUINO > 18 // Arduino 0019 or later #include <SPI.h> #endif #include <Ethernet.h> //#include <EthernetDNS.h> Only needed in Arduino 0022 or earlier #include <Twitter.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; byte ip[] = { 10, 0, 0, 177 }; Twitter twitter("<<< mi token>>>"); char msg[] = "mi mensaje";
void setup() { delay(1000); Ethernet.begin(mac); 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."); } }
void loop() { }
|
|
|
|
|
29
|
Using Arduino / Programming Questions / Re: help with alarm code
|
on: March 09, 2013, 05:01:38 pm
|
|
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???
|
|
|
|
|
30
|
Using Arduino / Programming Questions / help with alarm code
|
on: March 09, 2013, 04:51:47 pm
|
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 #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."); } } }
|
|
|
|
|