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
00001 #include"mbed.h" 00002 #include"Air_Quality.h" 00003 AirQuality airqualitysensor; 00004 int current_quality = -1; 00005 PinName analogPin = p15; 00006 00007 // Interrupt Handler 00008 void AirQualityInterrupt() 00009 { 00010 AnalogIn sensor(analogPin); 00011 airqualitysensor.last_vol = airqualitysensor.first_vol; 00012 airqualitysensor.first_vol = sensor.read()*1000; 00013 airqualitysensor.timer_index = 1; 00014 } 00015 00016 // Main loop 00017 int main() 00018 { 00019 airqualitysensor.init(analogPin, AirQualityInterrupt); 00020 while(1) { 00021 current_quality=airqualitysensor.slope(); 00022 if (current_quality >= 0) { // if a valid data returned. 00023 if (current_quality == 0) 00024 printf("High pollution! Force signal active\n\r"); 00025 else if (current_quality == 1) 00026 printf("High pollution!\n\r"); 00027 else if (current_quality == 2) 00028 printf("Low pollution!\n\r"); 00029 else if (current_quality == 3) 00030 printf("Fresh air\n\r"); 00031 } 00032 } 00033 }
Generated on Wed Aug 17 2022 05:19:24 by
1.7.2