Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remote control transmitter sketch
// transmitter 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;
const char *on2 = "a";
const char *off2 = "b";
const char *on3 = "c";
const char *off3 = "d";
void setup()
{
vw_set_ptt_inverted(true); // Required for RF Link modules
vw_setup(300); // set data speed
vw_set_tx_pin(12);
pinMode(8, INPUT);
pinMode(7, INPUT);
}
void loop()
{
if (digitalRead(8)==HIGH)
{
vw_send((uint8_t *)on2, strlen(on2)); // send the data out to the world
vw_wait_tx(); // wait a moment
delay(200);
}
if (digitalRead(8)==LOW)
{
vw_send((uint8_t *)off2, strlen(off2));
vw_wait_tx();
delay(200);
}
if (digitalRead(7)==HIGH)
{
vw_send((uint8_t *)on3, strlen(on3));
vw_wait_tx();
delay(200);
}
if (digitalRead(7)==LOW)
{
vw_send((uint8_t *)off3, strlen(off3));
vw_wait_tx();
delay(200);
}
}
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.