Library for MQ7 gas sensor

Dependents:   Garage_Control

Revision:
0:398854b7b855
Child:
1:beae29b45281
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MQ7.cpp	Sun Jul 02 11:37:29 2017 +0000
@@ -0,0 +1,21 @@
+#include "MQ7.h"
+#include "mbed.h"
+
+MQ7::MQ7(PinName pinA, PinName pinD) : _pinA(pinA), _pinD(pinD) {
+
+     
+}
+int MQ7::get_CO_value(){
+    float a = _pinA.read_u16();
+    printf("%f\r\n",a);
+    if(a<16384){
+        return 0;
+    }else if(a> 16383 && a<32768){
+        return 1;
+    }else if(a>32767 && a<49152){
+        return 2;
+    }else{
+        return 3;
+        }
+            
+}
\ No newline at end of file