Control Led from 2 buttons


hello everyone. intend control led wirelessly , locally works combined key, ocea can turn 1 side , on other or vice versa, or turn off , light either side.


hola todos. bueno lo que pretendo hacer es controlar un led de forma inalambrica y tambien de forma local de tal modo de que funcione como si fuera una llave combinada, ocea que lo pueda apagar de un lado y encender del otro o viceversa, o tan solo apagar y encender de cualquiera de los dos lados.




this link try project
este es el link de donde yo intento hacer el proyecto


control 433 tr rc

entiendo que debo hacer modificaciones en el sketch del receptor y al proyecto original agregarle un boton o switch en la protoboard como este
i understand must make modifications sketch of receiver , original project add button or switch on breadboard this

pushbutton
i've tried had no luck. : smiley-cry:
would appreciate provide me: smiley-mr-green:
lo intentado pero no tenido suerte. :smiley-cry:
agradeceria mucho la ayuda que me pudieran brindar ¡  :smiley-mr-green:

code: [select]
program code transmitter


/*
simplesend
this sketch transmits short text message using virtualwire library
connect transmitter data pin arduino pin 12
*/
#include
int switchpin = 8;
boolean lastbutton = low;
boolean currentbutton = low;
int check = 0;

void setup()
{
pinmode(switchpin, input);

// initialize io , isr
vw_setup(2000); // bits per sec
}

boolean debounce(boolean last)
{
boolean current = digitalread(switchpin);
if (last != current)
{
delay(5);
current = digitalread(switchpin);
}
return current;
}

void loop()
{
currentbutton = debounce(lastbutton);
if (lastbutton == low && currentbutton == high && check == 0)
{
send("on");
delay(500);
check = 1;
}
else

if (lastbutton == low && currentbutton == high && check == 1)
{
send("off");
delay(500);
check = 0;
}
}

void send (char *message)
{
vw_send((uint8_t *)message, strlen(message));
vw_wait_tx(); // wait until whole message gone
}






program code receiver


/*
simplereceive
this sketch displays text strings received using virtualwire
connect receiver data pin arduino pin 11
*/
#include
byte message[vw_max_message_len]; // buffer store incoming messages
byte messagelength = vw_max_message_len; // size of message
int relaypin = 7;

void setup()
{
pinmode(relaypin, output);
digitalwrite(relaypin, high);

serial.begin(9600);
serial.println("device ready");
// initialize io , isr
vw_setup(2000); // bits per sec
vw_rx_start(); // start receiver
}
void loop()
{
if (vw_get_message(message, &messagelength)) // non-blocking

{
serial.print("received: ");
for (int = 0; < messagelength; i++)
{
char c = message;
serial.print(c);

char on = 'on';
if(c == on)
{
digitalwrite(relaypin, low);
}
char off = 'of';

if(c == off)
{
digitalwrite(relaypin, high);
}

}
serial.println();
}
}


quote
char on = 'on';
single quotes single characters. please post picture of keyboard on key circled.

code: [select]
if(c == on)
never going true. 1 character sent on radio never going equal multi-byte character (which arduino doesn't handle worth damn anyway).


Arduino Forum > Using Arduino > Programming Questions > Control Led from 2 buttons


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code