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.
main.cpp
00001 #include "mbed.h" 00002 #include "MQ7.h" 00003 00004 DigitalOut led1(LED1); 00005 DigitalOut led2(LED2); 00006 DigitalOut led3(LED3); 00007 MQ7 sensor(p21, p22); // ALR, HSW 00008 00009 int main() { 00010 00011 while(1) { 00012 led1 = 0; 00013 led2 = 0; 00014 led3 = 0; 00015 00016 // Purge the device for 60 sec 00017 sensor.setHeat(1.0f); // supply full 5V to module 00018 led1 = 1; // Turn on only LED1 during Purge phase 00019 for (int i = 0; i < 60; i++){ 00020 wait(1); // wait 60 seconds 00021 } 00022 00023 // Purge complete 00024 // Sense the device for 90 sec 00025 sensor.setHeat(0.28f); // supply 1.4V to module 00026 led1 = 0; 00027 led2 = 1; // Turn on only LED2 during Sense phase 00028 for (int i = 0; i < 90; i++){ 00029 if (sensor.getAlarm() == 1) 00030 led3 = 1; // Turn on LED3 if CO gas levels reached 00031 wait(1); 00032 } 00033 // Sense complete, start over 00034 wait(0.5); 00035 } 00036 }
Generated on Tue Jul 12 2022 19:53:02 by
1.7.2