MQ-7 Gas Sensor demo

Dependencies:   mbed

Fork of Lab4_4180 by Bryan Bates

Files at this revision

API Documentation at this revision

Comitter:
gandhi1
Date:
Tue Apr 11 14:32:00 2017 +0000
Parent:
1:6f35304675ae
Commit message:
SensoreCO

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 6f35304675ae -r e128a186b567 main.cpp
--- a/main.cpp	Mon Oct 31 22:05:29 2016 +0000
+++ b/main.cpp	Tue Apr 11 14:32:00 2017 +0000
@@ -1,36 +1,16 @@
 #include "mbed.h"
 #include "MQ7.h"
 
-DigitalOut led1(LED1);
-DigitalOut led2(LED2);
-DigitalOut led3(LED3);
-MQ7 sensor(p21, p22); // ALR, HSW
+MQ7 sensor(D14, D15); // D0(non collegare), A0
 
 int main() {
     
     while(1) {
-        led1 = 0;
-        led2 = 0;
-        led3 = 0;
-        
-        // Purge the device for 60 sec
-        sensor.setHeat(1.0f); // supply full 5V to module
-        led1 = 1; // Turn on only LED1 during Purge phase
-        for (int i = 0; i < 60; i++){
-            wait(1); // wait 60 seconds
+        if (sensor.getAlarm()) {
+        printf("%\t CO è presente");
         }
-        
-        // Purge complete
-        // Sense the device for 90 sec 
-        sensor.setHeat(0.28f); // supply 1.4V to module
-        led1 = 0; 
-        led2 = 1; // Turn on only LED2 during Sense phase
-        for (int i = 0; i < 90; i++){
-            if (sensor.getAlarm() == 1)
-                led3 = 1; // Turn on LED3 if CO gas levels reached
-            wait(1); 
+        else {
+        printf("%\t CO NON c'è");
         }
-        // Sense complete, start over
-        wait(0.5);
     }
-}
+ }
\ No newline at end of file