TX code:
#include <VirtualWire.h>
char msg[1] = {'B'};
void setup()
{
// Initialise the IO and ISR
vw_set_tx_pin(0);
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
}
void loop()
{
vw_send((uint8_t *)msg, 1);
vw_wait_tx(); // Wait until the whole message is gone
delay(200);
}
RX code:
#include <VirtualWire.h>
int Trigger = 0; //Variable for the Recived Trigger
int i;
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
void setup()
{
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
// Initialise the IO and ISR
vw_set_rx_pin(8);
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
}
void loop()
{
if(vw_get_message(buf, &buflen)) // Non-blocking
{
Trigger = buf[i];
Serial.println(Trigger);
}
if(Trigger == 66) //ASCII for B, 066
{
digitalWrite(LED_BUILTIN, HIGH);
}
else()
{
digitalWrite(LED_BUILTIN, LOW);
}
}