Created
April 23, 2025 04:56
-
-
Save johnaboxall/2e994de9d1dde882ed80f11aac7ce1cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// transmitter sketch | |
// | |
#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