read only once
This commit is contained in:
parent
04bfaf4d94
commit
060fa80efd
@ -411,8 +411,7 @@ bool readSensors()
|
|||||||
rtcLastTemp2 = temp2.getAverage();
|
rtcLastTemp2 = temp2.getAverage();
|
||||||
|
|
||||||
/* Use the Ultrasonic sensor to measure waterLevel */
|
/* Use the Ultrasonic sensor to measure waterLevel */
|
||||||
for (int i = 0; i < 5; i++)
|
|
||||||
{
|
|
||||||
digitalWrite(SENSOR_SR04_TRIG, LOW);
|
digitalWrite(SENSOR_SR04_TRIG, LOW);
|
||||||
delayMicroseconds(2);
|
delayMicroseconds(2);
|
||||||
digitalWrite(SENSOR_SR04_TRIG, HIGH);
|
digitalWrite(SENSOR_SR04_TRIG, HIGH);
|
||||||
@ -421,8 +420,7 @@ bool readSensors()
|
|||||||
float duration = pulseIn(SENSOR_SR04_ECHO, HIGH);
|
float duration = pulseIn(SENSOR_SR04_ECHO, HIGH);
|
||||||
waterRawSensor.add((duration * .343) / 2);
|
waterRawSensor.add((duration * .343) / 2);
|
||||||
Serial << "Distance sensor " << duration << " ms : " << waterRawSensor.getAverage() << " cm" << endl;
|
Serial << "Distance sensor " << duration << " ms : " << waterRawSensor.getAverage() << " cm" << endl;
|
||||||
delay(20);
|
|
||||||
}
|
|
||||||
/* deactivate the sensors */
|
/* deactivate the sensors */
|
||||||
digitalWrite(OUTPUT_SENSOR, LOW);
|
digitalWrite(OUTPUT_SENSOR, LOW);
|
||||||
return leaveMode1;
|
return leaveMode1;
|
||||||
|
Loading…
Reference in New Issue
Block a user