Commit 39fbc856 authored by user2684's avatar user2684
Browse files

delay() replaced with wait()

parent ce0b430f
...@@ -22,7 +22,7 @@ float getVcc() { ...@@ -22,7 +22,7 @@ float getVcc() {
ADMUX = (_BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1)); ADMUX = (_BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1));
#endif #endif
// Vref settle // Vref settle
delay(70); wait(70);
// Do conversion // Do conversion
ADCSRA |= _BV(ADSC); ADCSRA |= _BV(ADSC);
while (bit_is_set(ADCSRA, ADSC)) {}; while (bit_is_set(ADCSRA, ADSC)) {};
...@@ -681,7 +681,7 @@ float SensorMQ::_MQCalibration() { ...@@ -681,7 +681,7 @@ float SensorMQ::_MQCalibration() {
//take multiple samples //take multiple samples
for (i=0; i< _calibration_sample_times; i++) { for (i=0; i< _calibration_sample_times; i++) {
val += _MQResistanceCalculation(analogRead(_pin)); val += _MQResistanceCalculation(analogRead(_pin));
delay(_calibration_sample_interval); wait(_calibration_sample_interval);
} }
//calculate the average value //calculate the average value
val = val/_calibration_sample_times; val = val/_calibration_sample_times;
...@@ -697,7 +697,7 @@ float SensorMQ::_MQRead() { ...@@ -697,7 +697,7 @@ float SensorMQ::_MQRead() {
float rs=0; float rs=0;
for (i=0; i<_read_sample_times; i++) { for (i=0; i<_read_sample_times; i++) {
rs += _MQResistanceCalculation(analogRead(_pin)); rs += _MQResistanceCalculation(analogRead(_pin));
delay(_read_sample_interval); wait(_read_sample_interval);
} }
rs = rs/_read_sample_times; rs = rs/_read_sample_times;
return rs; return rs;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment