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:
- mbedAustin
- Date:
- 2014-09-05
- Revision:
- 1:888328032581
- Parent:
- 0:2dbce8e35862
- Child:
- 2:225383599b95
File content as of revision 1:888328032581:
#include"mbed.h"
#include"Air_Quality.h"
AirQuality airqualitysensor;
int current_quality = -1;
PinName analogPin = A0;
// 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");
}
}
}