OpenGarage Forums OpenGarage Firmware Announcing OpenGarage Firmware 1.0.6 Reply To: Announcing OpenGarage Firmware 1.0.6

#596

lawrence_jeff
Participant

Zipp,
I had this issue also – Do you not have the distance sensor attached? If not there are some sensing loops the code gets stuck in and this causes a WDT reset. This updated function will fix it

ulong OpenGarage::read_distance_once() {
digitalWrite(PIN_TRIG, LOW);
delayMicroseconds(2);
digitalWrite(PIN_TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(PIN_TRIG, LOW);
// wait till echo pin’s rising edge
unsigned long quit_time=micros()+32767L;
while((digitalRead(PIN_ECHO)==LOW)&& (micros()<quit_time));
//Do nothing
unsigned long start_time = micros();
quit_time=start_time+32767L;
//wait till echo pin’s falling edge
while((digitalRead(PIN_ECHO)==HIGH) && (micros()<quit_time));
ulong lapse = micros() – start_time;
if (lapse>32767L) lapse = 32767L;
return lapse;
}