Page 1 of 1

Sonar codebug - ultrasonic ranger

Posted: Fri Oct 30, 2015 9:01 pm
by mikerr
Use a HC-SR04 ultrasonic sensor with the codebug to detect / measure distance:

- leg 0 set as input, with pullups disabled
- pull down resisitor across leg 0 and ground

Code sends a 10ms pulse, and listens for it's echo.
"distance" is measured by the delay of the echo in ms

Image
https://www.youtube.com/watch?v=Ps05LsqzzxE

Image

Distance value is around 1/3 the measurement in cm
e.g. distance value of 5 is 15cm

The sensor is good to around 2 meters

http://www.codebug.org.uk/explore/codeb ... onar-eyes/

Re: Sonar codebug - ultrasonic ranger

Posted: Sat Oct 31, 2015 10:45 am
by mikerr
I should add that the sensor only works reliably at 5v
it gets jumpy and inaccurate down to 3.5 and not at all at 3v.

Re: Sonar codebug - ultrasonic ranger

Posted: Sun Feb 21, 2016 4:38 pm
by Gyuri
How much resistance?

Re: Sonar codebug - ultrasonic ranger

Posted: Tue Mar 22, 2016 2:35 pm
by mikerr
Anything around 10k is ok