-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
59 lines (40 loc) · 1.06 KB
/
main.cpp
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
#include <rtos.h>
#include <timer.h>
#include <Loka.h>
#include <console.h>
/*
* Please notice that the sensor should be powered for 2 minutes before you can get acurate mesurments.
*
* */
void setup() {
//Disable board watchdog
Board::disableWatchdog();
console_close();
// to supply the sensor with 3V
Board::set24MHzBoosterOnMode();
console_init();
}
void loop(){
// connected to the port 1 (A0) could be conneted on port2 too.
// Read and print de analog Value for Pin A0 (value between 0 and 1023, from 0V to 2.5V)
unsigned int airQuality = Loka::analogRead(A0);
console_debug("Air Quality Level: %d",airQuality);
//these thresholds could be ajusted
if(airQuality>700){
console_debug("High Pollution Level!\r\n");
}else if(airQuality>300){
console_debug("Low Pollution Level!\r\n");
}else{
console_debug("Fresh Air!\r\n");
}
//Sleep for 1 second
delay(1000);
}
int main(void) {
//Board init with debug enabled
tc_rtos_init(1);
setup();
for(;;)
loop();
//return 0;
}