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. :-)
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.
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.
Need help with a hardware project or product? Drop us an email at firstname.lastname@example.org. We offer consulting services on AVR and Nordic nRF BLE - hardware design, firmware development, prototyping, PCB design/assembly, sourcing and manufacturing. We can help you bring your product to market!
We love hearing from our readers. Email us at email@example.com for questions or comments on this article. If you found this article useful, please support us by buying some of our hardware products.