![](/media/cache/profiles/P1080070.JPG.50x50_q85.jpg)
Grove Air quality sensor program
Dependencies: Grove_Air_Quality_Sensor_Library mbed
Connection
VDD → 3.3V or 5V (supply voltage)
GND → GND
SIG → p15 (mbed)
NC → Non connection
main.cpp@0:2dbce8e35862, 2014-09-05 (annotated)
- Committer:
- mbedAustin
- Date:
- Fri Sep 05 03:39:31 2014 +0000
- Revision:
- 0:2dbce8e35862
- Child:
- 1:888328032581
Grove Air Quality sensor example application. Test the air quality every 5 seconds and report. Score quality from 0-100 like the daily weather report.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedAustin | 0:2dbce8e35862 | 1 | #include "mbed.h" |
mbedAustin | 0:2dbce8e35862 | 2 | |
mbedAustin | 0:2dbce8e35862 | 3 | AnalogIn sensor(A0); |
mbedAustin | 0:2dbce8e35862 | 4 | |
mbedAustin | 0:2dbce8e35862 | 5 | int main() { |
mbedAustin | 0:2dbce8e35862 | 6 | float sensorValue; |
mbedAustin | 0:2dbce8e35862 | 7 | while (true) { |
mbedAustin | 0:2dbce8e35862 | 8 | sensorValue = sensor.read(); |
mbedAustin | 0:2dbce8e35862 | 9 | printf("\r Air Quality score = %3.2f",100 - (sensorValue*100)); |
mbedAustin | 0:2dbce8e35862 | 10 | wait(5); |
mbedAustin | 0:2dbce8e35862 | 11 | } |
mbedAustin | 0:2dbce8e35862 | 12 | } |