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: SmartKitchen_MiniProject SmartKitchen_MiniProject_RTES
Diff: MQ2.cpp
- Revision:
- 8:6eba34552ceb
- Parent:
- 6:c0ebeb4b47b6
- Child:
- 9:54c2e1d69508
--- a/MQ2.cpp Wed Nov 08 10:43:37 2017 +0000
+++ b/MQ2.cpp Tue Jun 22 12:34:07 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(50ms);
}
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(50ms);
}
rs = rs/READ_SAMPLE_TIMES;
return rs;