Created
June 10, 2017 08:39
-
-
Save DzikuVx/0e60cd63bf222dba6f78d57c5849155b to your computer and use it in GitHub Desktop.
This file contains 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
#include <VirtualWire.h> | |
uint8_t currentPacket = 0; | |
void setup() { | |
/* | |
* Set TX pin -> Connect FS1000A here | |
*/ | |
vw_set_tx_pin(12); | |
/* | |
* Set RX pin -> Connect XY-MK-5V here | |
*/ | |
vw_set_rx_pin(11); | |
/* | |
* Set transmission speed. Reciver and trasmitter have to use the same speed | |
*/ | |
vw_setup(1000); | |
/* | |
* Start to listen. Required on receiver side | |
*/ | |
vw_rx_start(); | |
} | |
void loop() { | |
uint8_t buf[VW_MAX_MESSAGE_LEN]; | |
uint8_t buflen = VW_MAX_MESSAGE_LEN; | |
if (vw_get_message(buf, &buflen)) { | |
/* | |
* Recived packet, if checksum is correct, is avalable in buf variable | |
* Send it over Serial, or do whatever you want with it | |
*/ | |
currentPacket = (uint8_t) buf[0]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment