Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Grove_Air_Quality_Sensor_Library mbed
main.cpp
- Committer:
- HeptaSatTraining2019
- Date:
- 2019-11-06
- Revision:
- 2:225383599b95
- Parent:
- 1:888328032581
File content as of revision 2:225383599b95:
#include"mbed.h" #include"Air_Quality.h" AirQuality airqualitysensor; int current_quality = -1; PinName analogPin = p15; // Interrupt Handler void AirQualityInterrupt() { AnalogIn sensor(analogPin); airqualitysensor.last_vol = airqualitysensor.first_vol; airqualitysensor.first_vol = sensor.read()*1000; airqualitysensor.timer_index = 1; } // Main loop int main() { airqualitysensor.init(analogPin, AirQualityInterrupt); while(1) { current_quality=airqualitysensor.slope(); if (current_quality >= 0) { // if a valid data returned. if (current_quality == 0) printf("High pollution! Force signal active\n\r"); else if (current_quality == 1) printf("High pollution!\n\r"); else if (current_quality == 2) printf("Low pollution!\n\r"); else if (current_quality == 3) printf("Fresh air\n\r"); } } }