-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreceiver.c
57 lines (49 loc) · 1.13 KB
/
receiver.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <VirtualWire.h>
#include <LiquidCrystal.h>
/*
* Arduino 433MHz Receiver Demo
*
* Donovan Prehn
* Peter Scherminski
*/
/* Physical Connections
*
* UNO -> XY-MK-5V
* 5V ----------- VCC
* 11 ----------- DATA
* ----------- DATA
* GND ----------- GND
*/
const int recvPin = 11;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup()
{
//USB Serial Monitor Debugging
Serial.begin(9600);
Serial.println("setup()");
// LCD Screen Shield
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0,0);
//VirtualWire
vw_set_rx_pin(recvPin);
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
//Refresh LCD Screen
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Light Val: ");
int i;
for(i=0; i<buflen; i++){
lcd.print(char(buf[i]));
}
}
}