Sonar codebug - ultrasonic ranger

Post your projects here
Post Reply
mikerr
Posts: 86
Joined: Fri Jul 31, 2015 10:37 am
Contact:

Sonar codebug - ultrasonic ranger

Post 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/
Twitter @mikered codebug profile mikerr
mikerr
Posts: 86
Joined: Fri Jul 31, 2015 10:37 am
Contact:

Re: Sonar codebug - ultrasonic ranger

Post 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.
Twitter @mikered codebug profile mikerr
Gyuri
Posts: 1
Joined: Sun Feb 21, 2016 10:21 am

Re: Sonar codebug - ultrasonic ranger

Post by Gyuri »

How much resistance?
mikerr
Posts: 86
Joined: Fri Jul 31, 2015 10:37 am
Contact:

Re: Sonar codebug - ultrasonic ranger

Post by mikerr »

Anything around 10k is ok
Twitter @mikered codebug profile mikerr
Post Reply