-
Notifications
You must be signed in to change notification settings - Fork 0
/
Receiver Code.ino
68 lines (43 loc) · 1.9 KB
/
Receiver Code.ino
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
58
59
60
61
62
63
64
65
66
67
68
//Receiver Code For Wireless Health Monitoring System
#include <RH_ASK.h> // Include RadioHead Amplitude Shift Keying Library
#include <SPI.h> // Include dependant SPI Library
#include <LiquidCrystal.h> //Include LCD library
LiquidCrystal lcd(8, 6 , 5, 4, 3, 2); // sets the interfacing pins // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7) //
RH_ASK rf_driver; // Create Amplitude Shift Keying Object
char StringReceived[22]; //setting maximum string length
int a,b;
void setup()
{
lcd.setCursor(0,0);
delay(100);
lcd.begin(16,2); //initializing LCD 16*2 display
rf_driver.init(); //calling class driver initialization function
Serial.begin(9600); // Setup Serial Monitor
}
void loop()
{
uint8_t buf[24]; // Set buffer to size of expected message
uint8_t buflen = sizeof(buf);
if (rf_driver.recv(buf, &buflen)) // Check if received packet is correct size
{
int i;
// Message with a good checksum received, dump it.
for (i = 0; i < buflen; i++)
{
StringReceived[i] = char(buf[i]); // chars from buffer.
}
sscanf(StringReceived, "%d,%d",&a,&b); // Converts a string to an array
// Turn off light to and await next message
Serial.println(StringReceived); //printing received string to serial monitor
lcd.clear();
lcd.setCursor(0,0);
lcd.print("HeartRate=");
lcd.print(a); //printing the value of heart beat to LCD
lcd.print("_BPM");
lcd.setCursor(0,1);
lcd.print("Temp=");
lcd.print(b); //printing the value temperature to the lcd
lcd.print(" *C");
}
memset( StringReceived, 0, sizeof( StringReceived));// This line is for reset the StringReceived
}