-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
53 lines (46 loc) · 1.08 KB
/
main.c
File metadata and controls
53 lines (46 loc) · 1.08 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
#include <stdio.h>
#include <string.h>
#include "pico/stdlib.h"
#include "hardware/gpio.h"
#include "include/readTemp.h"
#include "include/leds.h"
#include "include/buzzer.h"
#include "include/alert.h"
#include "include/display.h"
const uint8_t LOWER_TEMP_LIMIT = 28;
const uint8_t HIGHER_TEMP_LIMIT = 30;
const uint8_t TEMP_SENSOR_PIN = 16;
int main()
{
stdio_init_all();
setup_display();
setup_buzzer();
gpio_init(TEMP_SENSOR_PIN);
float temp_sens;
while (1)
{
do
{
temp_sens = getTemperature(TEMP_SENSOR_PIN);
} while (temp_sens < -999);
printf("%f\r\n", temp_sens);
msg_temp_value(temp_sens);
if (temp_sens < LOWER_TEMP_LIMIT)
{
alert_event();
msg_state_temp(" temp baixa ");
}
else if (temp_sens > HIGHER_TEMP_LIMIT)
{
alert_event();
msg_state_temp(" temp alta ");
}
else
{
safe_event();
msg_state_temp("temp estavel");
}
sleep_ms(500);
};
return 0;
}