]> git.piffa.net Git - sketchbook_andrea/blob - hardware/rf315_433/reciver/reciver.ino
RF e keypad
[sketchbook_andrea] / hardware / rf315_433 / reciver / reciver.ino
1 //simple Tx on pin D12
2 //Written By : Mohannad Rawashdeh
3 // 3:00pm , 13/6/2013
4 //http://www.instructables.com/id/RF-315433-MHz-Transmitter-receiver-Module-and-Ardu/step3/Arduino-Virtual-Wire-Library/
5 //..................................
6 // VirtualWire.h :   wiring.h  ->    Arduino.h
7 // VirtualWire.cpp : WProgram.h -> Arduino.h
8 #include <VirtualWire.h>
9 void setup()
10 {
11   vw_set_ptt_inverted(true); // Required for DR3100
12   vw_set_rx_pin(12);
13   vw_setup(4000);  // Bits per sec
14   pinMode(13, OUTPUT);
15
16   vw_rx_start();       // Start the receiver PLL running
17 }
18 void loop()
19 {
20   uint8_t buf[VW_MAX_MESSAGE_LEN];
21   uint8_t buflen = VW_MAX_MESSAGE_LEN;
22
23   if (vw_get_message(buf, &buflen)) // Non-blocking
24   {
25     if(buf[0]=='1'){
26
27
28       digitalWrite(13,1);
29     }  
30     if(buf[0]=='0'){
31       digitalWrite(13,0);
32     }
33
34   }
35 }
36