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.
Dependents: MQ4_example Navitec-Firmware
Revision 1:d64cac41351a, committed 2021-04-04
- Comitter:
- renanbmx123
- Date:
- Sun Apr 04 14:38:22 2021 +0000
- Parent:
- 0:401959f72658
- Commit message:
- Refatorado;
Changed in this revision
| MQ4.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/MQ4.cpp Tue Jul 17 04:34:21 2018 +0000
+++ b/MQ4.cpp Sun Apr 04 14:38:22 2021 +0000
@@ -59,7 +59,8 @@
float val=0;
for (int i=0;i<CALIBARAION_SAMPLE_TIMES;i++) { //take multiple samples
val += MQResistanceCalculation(_pin.read_u16()>>6);
- wait_ms(CALIBRATION_SAMPLE_INTERVAL);
+ //wait_ms(CALIBRATION_SAMPLE_INTERVAL);
+ ThisThread::sleep_for(chrono::milliseconds(CALIBRATION_SAMPLE_INTERVAL));
}
val = val/CALIBARAION_SAMPLE_TIMES; //calculate the average value
val = val/RO_CLEAN_AIR_FACTOR; //divided by RO_CLEAN_AIR_FACTOR yields the Ro according to the chart in the datasheet
@@ -79,7 +80,8 @@
float rs=0;
for (i=0;i<READ_SAMPLE_TIMES;i++) {
rs += MQResistanceCalculation(_pin.read_u16()>>6);
- wait_ms(READ_SAMPLE_INTERVAL);
+ //wait_ms(READ_SAMPLE_INTERVAL);
+ ThisThread::sleep_for(chrono::milliseconds(READ_SAMPLE_INTERVAL));
}
rs = rs/READ_SAMPLE_TIMES;
return rs;