MQ-7 Gas Sensor demo

Dependencies:   mbed

Dependents:   GloboMet

Revision:
0:ff650029fdf8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MQ7.h	Mon Oct 31 21:59:53 2016 +0000
@@ -0,0 +1,34 @@
+
+#ifndef MQ7_H
+#define MQ7_H
+
+#include "mbed.h"
+
+// Interface to control an MQ-7 (Carbon Monoxide) sensor 
+
+class MQ7 {
+public:
+
+    /** Create interfaces with gas sensor module
+     *
+     * @param alr A DigitalIn, alarm output to microcontroller
+     * @param hsw A PwmOut, heat switch input from microcontroller, active low
+     */
+    MQ7(PinName alr, PinName hsw) : _alr(alr), _hsw(hsw){}
+    
+    int getAlarm(){
+        return _alr.read();
+    }
+    
+    void setHeat(float voltage){
+        _hsw.write(voltage);
+    }
+     
+
+protected:
+    DigitalIn _alr;
+    PwmOut _hsw;
+
+};
+
+#endif
\ No newline at end of file