Example of using the mq2 library

Dependencies:   MQ2

Revision:
0:1e2a25e50796
Child:
1:e589b168e253
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 05 11:55:21 2017 +0000
@@ -0,0 +1,23 @@
+#include "mbed.h"
+#include "MQ2.h"
+
+Serial pc(USBTX, USBRX); // tx, rx
+MQ2 mq2(A1);                                                                    // Analog Port to read from
+
+int main() {
+    pc.baud(115200);
+    mq2.begin();                                                                // 'Calibrate' sensor
+    MQ2_data_t MQ2_data;                                                        // Structure to hold data.
+    while (true) {
+        pc.printf("CO PPM: %.0f\r\n",mq2.readCO());                             // Performs a one shot read of CO
+        pc.printf("Smoke PPM: %.0f\r\n",mq2.readSmoke());                       // Performs a one shot read of Smoke
+        pc.printf("LPG PPM: %.0f\r\n",mq2.readLPG());                           // Performs a one shot read of LPG
+        wait(5);
+        mq2.read(&MQ2_data);                                                    // Alt reading method, reading to struct
+        pc.printf("CO PPM: %.0f\r\n",MQ2_data.co);                              // Return data from strut
+        pc.printf("Smoke PPM: %.0f\r\n",MQ2_data.smoke);                        // Return data from strut
+        pc.printf("LPG PPM: %.0f\r\n",MQ2_data.lpg);                            // Return data from strut
+        wait(5);
+    }
+}
+