p4labs / p4-robotsim

2D Arduino robot simulation powering Dawson Engineering Physics Virtual Lab
MIT License
6 stars 1 forks source link

Ultrasonic Sensor always expect a distance #3

Open tawjaw opened 2 years ago

tawjaw commented 2 years ago

The ultrasonic sensor always has a distance. In the robot environment, if an object is not detected it sets the distance to be the maximum distance.

However, if the echo is not detected back the echo pin wouldn't change and then something like

  duration = pulseIn(echoPin, HIGH);

would time out.