Ultrasonic sensor HC-SR04 with Dagu Mini Driver on a Robot Chassis 1

I am working on a Raspberry Pi based robot, and recently acquired a Dagu chassis and a Dagu Mini Driver for this project. As soon as I had the mini driver hooked up and the wheels starts turning, I felt an irresistible urge 😉 to put an ultrasonic sensor on the chassis and have it roam around by itself.

I’ve written about hooking up the inexpensive and fun Ultrasonic sensor HC-SR04 with an Arduino before. The wiring is the same – instead of a real Ardunio board, we’re just using the Arduino compatible Dagu Mini driver here. You can see some details for this board at the link below. Unfortunately, they don’t give you the full schematics.


As far as construction goes, the Dagu chassis is very easy to put together. It can, and in fact it was put together by a 9 year old. 🙂

Ultrasonic sensor HC-SR04 with Dagu Mini Driver on a Robot Chassis 2

Also as you can see, I’ve used very high tech Tie Wrap Technology to attach the sensor to the chassis. 😉

The motors and the board are powered by a 3000 mAh 1A Anker rechargeable battery – good stuff!

The programming part is quite simple. The main loop sends out a ping on the ultrasonic sensor. If it returns a distance less than a set threshold the wheels are made to stop and reverse. Then, the chassis is made to turn left by a bit, and this process repeats. This is a very simplistic algorithm, but you can modify it for more sophisticated behavior.

You can see the robot in action in the video below.

For privacy reasons Vimeo needs your permission to be loaded.
I Accept

Here is the full source code:

Not a complex project by a long shot. But it was a great fun detour for me, and I hope you find some useful information here.