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.
Dependencies: MQ2
main.cpp
00001 #include "mbed.h" 00002 #include "MQ2.h" 00003 00004 Serial pc(USBTX, USBRX); // tx, rx 00005 MQ2 mq2(A1); // Analog Port to read from 00006 00007 int main() { 00008 pc.baud(115200); 00009 mq2.begin(); // 'Calibrate' sensor 00010 MQ2_data_t MQ2_data; // Structure to hold data. 00011 while (true) { 00012 pc.printf("CO PPM: %.0f\r\n",mq2.readCO()); // Performs a one shot read of CO 00013 pc.printf("Smoke PPM: %.0f\r\n",mq2.readSmoke()); // Performs a one shot read of Smoke 00014 pc.printf("LPG PPM: %.0f\r\n",mq2.readLPG()); // Performs a one shot read of LPG 00015 wait(1); 00016 pc.printf("................................\r\n"); 00017 mq2.read(&MQ2_data); // Alt reading method, reading to struct 00018 pc.printf("CO PPM: %.0f\r\n",MQ2_data.co); // Return data from strut 00019 pc.printf("Smoke PPM: %.0f\r\n",MQ2_data.smoke); // Return data from strut 00020 pc.printf("LPG PPM: %.0f\r\n",MQ2_data.lpg); // Return data from strut 00021 pc.printf("................................\r\n"); 00022 pc.printf("E' caldo\r\n"); 00023 wait(1); 00024 } 00025 } 00026
Generated on Thu Jul 14 2022 22:36:33 by
1.7.2