Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Seeifultrasonicsensorvaluehasnotchangedforaperiodoftimearduino

I have recently gotten into a bit of simple robotics and arduino programming. I have a decent amount of prior knowledge in programming but arduino is new to me. I bought a small robotics kit to have something simple to start with, its just one of the Elegoo smart cars. I have been experimenting with the sample code for the object avoidance car that uses the ultrasonic sensor to avoid objects, however the sensor is not perfect and sometimes does not pick up more narrow things like chair legs. To combat this I am attempting to write code to detect when the car is stopped. My plan is to use the ultrasonic sensor to detect if the distance value has not changed for about 10 seconds and if it has not the car will perform a maneuver to try and get unstuck. The problem I am encountering is I do not know how to perform a function if a certain interval of time has passed. I have searched the web and cannot find much information on the subject.

TLDR; I need to know how to measure if the ultrasonic sensor value has not changed for a period of time.

Thank you all!

Comments