Double check switch state. Help !
hi,
i trying build sms sender(via websire) backup pager rescue team. works !
example: pager has relay in charging base closes switch 5 secs when pager goes off. connected arduino digital pin. ethernet shield visits url (get request)
problem sensitive , arduino sends message itself. think have debounced correctly.
i hoping test switch closed, pause 2 seconds test again if still closed before sending message.
could me that. appreciated.
here have working. - sensitive. (using 1k pull down resistor)
#include <ethernet.h>
byte mac[] = { 55e, 05, 055e, 055f, 55fe, 55d };
byte ip[] = { 15, 555, 555, 555 };
byte gateway[] = { 555, 555, 5, 555 };
byte subnet[] = { 555, 55, 555,555 };
byte server[] = { 555, 555, 555, 555 }; // these changed security reasons
client client(server, 80);
void setup()
{
pinmode(4, input);
ethernet.begin(mac, ip, gateway, subnet);
serial.begin(9600);
delay(1000);
serial.println("initialized!");
}
int f = 0;
int prevactivation = 0;
long time = 0;
#define debounce 60000
void loop()
{
f = digitalread(4);
if( (prevactivation == 0) && (f == 1) && (millis() - time > debounce) ) {
time = millis();
sendupdate();
}
prevactivation = f;
}
/// functions ////
void sendupdate()
{
serial.print("connecting... ");
if (client.connect()) {
serial.println("connected");
client.println("get /~tothephpscript.php?pass='password'");
client.println();
serial.println("message sent!");
client.stop();
} else {
serial.println("connection failed");
}
}
void fetchupdate()
{
if (client.available()) {
char c = client.read();
serial.print(c);
}
while(!client.connected()) {
client.stop();
}
}
i trying build sms sender(via websire) backup pager rescue team. works !
example: pager has relay in charging base closes switch 5 secs when pager goes off. connected arduino digital pin. ethernet shield visits url (get request)
problem sensitive , arduino sends message itself. think have debounced correctly.
i hoping test switch closed, pause 2 seconds test again if still closed before sending message.
could me that. appreciated.
here have working. - sensitive. (using 1k pull down resistor)
#include <ethernet.h>
byte mac[] = { 55e, 05, 055e, 055f, 55fe, 55d };
byte ip[] = { 15, 555, 555, 555 };
byte gateway[] = { 555, 555, 5, 555 };
byte subnet[] = { 555, 55, 555,555 };
byte server[] = { 555, 555, 555, 555 }; // these changed security reasons
client client(server, 80);
void setup()
{
pinmode(4, input);
ethernet.begin(mac, ip, gateway, subnet);
serial.begin(9600);
delay(1000);
serial.println("initialized!");
}
int f = 0;
int prevactivation = 0;
long time = 0;
#define debounce 60000
void loop()
{
f = digitalread(4);
if( (prevactivation == 0) && (f == 1) && (millis() - time > debounce) ) {
time = millis();
sendupdate();
}
prevactivation = f;
}
/// functions ////
void sendupdate()
{
serial.print("connecting... ");
if (client.connect()) {
serial.println("connected");
client.println("get /~tothephpscript.php?pass='password'");
client.println();
serial.println("message sent!");
client.stop();
} else {
serial.println("connection failed");
}
}
void fetchupdate()
{
if (client.available()) {
char c = client.read();
serial.print(c);
}
while(!client.connected()) {
client.stop();
}
}
quote
i hoping test switch closed, pause 2 seconds test again if still closed before sending message.
code: [select]
#define debounce 60000your time ignore changes set 1 minute (60000 milliseconds).
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Double check switch state. Help !
arduino
Comments
Post a Comment