]> git.piffa.net Git - sketchbook_andrea/blob - hardware/rf315_433/string_rx/string_rx.ino
RF string
[sketchbook_andrea] / hardware / rf315_433 / string_rx / string_rx.ino
1 /* String RX
2
3 Send a string with a XD-RF-5V
4 - https://mashenarduinoprojects.wordpress.com/projects/arduino-315330433mhz-transmitterreceiver-xd-fstxd-rf-5v/
5 */
6
7 #include <VirtualWire.h>
8  // recive
9 void setup()
10 {
11     Serial.begin(9600);          // Configure the serial connection to the computer
12     vw_set_ptt_inverted(true);  // Required by the RF module
13     vw_setup(2000);            // bps connection speed
14     vw_set_rx_pin(3);         // Arduino pin to connect the receiver data pin
15     vw_rx_start();           // Start the receiver
16     Serial.print("Reciver engaged");
17 }
18  
19 void loop()
20 {
21
22   uint8_t buf[VW_MAX_MESSAGE_LEN];
23   uint8_t buflen = VW_MAX_MESSAGE_LEN;
24   if (vw_get_message(buf, &buflen))      // We check if we have received data
25   {
26     int i;
27     // Message with proper check    
28     for (i = 0; i < buflen; i++)
29     {
30       Serial.write(buf[i]);  // The received data is stored in the buffer
31                             // and sent through the serial port to the computer
32     }
33     Serial.println();
34    
35   }
36 }
37