Hello everyone. Well what I intend to do is to control an LED wirelessly and also locally so that it works like a combined key, ocea who can turn from one side and on the other or vice versa, or just turn off and light from either side.
Hola a 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 is the link where I try to do the project
Este es el link de donde yo intento hacer el proyecto
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 that I must make modifications to the sketch of the receiver and the original project to add a button or switch on the breadboard like this
PushButton
I've tried but I had no luck. : smiley-cry:
Would greatly appreciate the help you could provide me: smiley-mr-green:
Lo he intentado pero no he tenido suerte. ![]()
Agradeceria mucho la ayuda que me pudieran brindar ¡ ![]()
Program code for the transmitter
/*
SimpleSend
This sketch transmits a short text message using the VirtualWire library
connect the Transmitter data pin to Arduino pin 12
*/
#include
int switchPin = 8;
boolean lastButton = LOW;
boolean currentButton = LOW;
int check = 0;
void setup()
{
pinMode(switchPin, INPUT);
// Initialize the IO and 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 the whole message is gone
}
Program code for the receiver
/*
SimpleReceive
This sketch displays text strings received using VirtualWire
Connect the Receiver data pin to Arduino pin 11
*/
#include
byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message
int relayPin = 7;
void setup()
{
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, HIGH);
Serial.begin(9600);
Serial.println("Device is ready");
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver
}
void loop()
{
if (vw_get_message(message, &messageLength)) // Non-blocking
{
Serial.print("Received: ");
for (int i = 0; i < 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();
}
}