Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remote control receiver sketch
// receiver sketch
//
// https://pmdway.com/blogs/product-guides-for-arduino/tutorial-using-long-range-315mhz-rf-wireless-transceivers-with-arduino
//
#include <VirtualWire.h>
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
void setup()
{
vw_set_ptt_inverted(true); // Required for RF link modules
vw_setup(300);
vw_set_rx_pin(11);
vw_rx_start();
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
}
void loop()
{
if (vw_get_message(buf, &buflen))
{
switch(buf[0])
{
case 'a':
digitalWrite(2, HIGH);
break;
case 'b':
digitalWrite(2, LOW);
break;
case 'c':
digitalWrite(3, HIGH);
break;
case 'd':
digitalWrite(3, LOW);
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.