1 sensor using RTOS Timer, another 2 over RTOS Semaphore
Dependents: Autonomous_quadcopter
Fork of HCSR04 by
Diff: hcsr04.cpp
- Revision:
- 6:7f98f258e8ef
- Parent:
- 5:02948ae78be7
- Child:
- 7:dcf0aa89bcd7
diff -r 02948ae78be7 -r 7f98f258e8ef hcsr04.cpp --- a/hcsr04.cpp Sun Feb 04 15:20:37 2018 +0000 +++ b/hcsr04.cpp Sun Feb 18 17:10:25 2018 +0000 @@ -25,7 +25,9 @@ while(!self->echo){ if(self->timer.read_us() > 4500){ //printf("moc1\n\r"); - break; + // if no response from distance sensor -> let the quadcopter fall + self->distan = 500; + return; } } if(self->timer.read_us() < 4500){ @@ -35,7 +37,9 @@ while(self->echo){ if(self->timer.read_us() > 4500){ //printf("moc2\n\r"); - break; + // if no response from distance sensor -> let the quadcopter fall + self->distan = 500; + return; } } self->timer.stop();