Hello everyone.
I have an Ultrasonic Sensor (distance sensor) and i want to calculate how much time something is in front of it (lets say from 10 to 200cm).
What method should i use? Is it possible with the millis() method or the use of a timer?
Thanks
you will get more help if you link to the sensor you're using
Your post does not make much sense.
I want to calculate how much time something is in front of it
Are you trying to calculate how long it will be until a robot reaches that object? Please post link to everything being used and give us more than a few unclear details!
The sensor i'm using is at this link:
http://arduinobasics.blogspot.gr/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.html
What i would like to do is at the void loop of the code given at the link to set a chronometer when "else{ }" occurs.
For instance, if i put my hand in front of the sensor (between maximum and minimum distance) for 5 sec, i would like the program to print 5.
I did it.
Thanks
Awesome! Did my code help?
It did,yes (with the proper adjustment)
Glad to hear that!