-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
65 lines (57 loc) · 1.44 KB
/
main.c
File metadata and controls
65 lines (57 loc) · 1.44 KB
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
/*
* DHT11.c
*
* Created: 27-11-2021 12.11.30 AM
* Author : Gaurav & Kishan
*/
#define F_CPU 1000000UL
#include <avr/io.h>
#include <util/delay.h>
#include <stdlib.h>
#include <stdio.h>
#include "Lcd.h"
#include "DHT11.h"
uint8_t I_hum,D_hum,I_temp,D_temp,checksum;
int main(void)
{
DDRA = 0xFF;
DDRC = 0xFF;
//char data[5];
lcd_init(); //initialize lcd
lcd_clear();
lcd_gotoxy(1,1);
lcd_Display_String("Humidity = ");
lcd_gotoxy(1,2);
lcd_Display_String("Temp = ");
while (1)
{
request(); //send start pulse
response(); //receive confirmation
I_hum = Receive_data(); //store 1st 1byte int data of humidity
D_hum = Receive_data(); //store next 1byte decimal data of humidity
I_temp= Receive_data(); //store next 1byte int data of temperature
D_temp= Receive_data(); //store next 1byte decimal data of temperature
checksum= Receive_data();//store next 1byte data in checksum for verification
if ((I_hum + D_hum + I_temp + D_temp) != checksum)
{
lcd_gotoxy(1,1);
lcd_Display_String("Error");
}
else
{
lcd_gotoxy(11,1);
lcd_Display_Integer(I_hum);
lcd_Display_String(".");
lcd_Display_Integer(D_hum);
lcd_Display_String("%");
lcd_gotoxy(7,2);
lcd_Display_Integer(I_temp);
lcd_Display_String(".");
lcd_Display_Integer(D_temp);
lcd_Display_String("C");
lcd_Display_String(" ");
lcd_Display_Integer(checksum);
}
_delay_ms(10);
}
}