Back to the toy car: My experiments with Raspberry PI

What can I do with Raspberry PI?

It is a B+ model. To use it as a fan-less credit-card computer and do browsing? Nah.. it sucks. Too slow to respond. To connect to TV and make it "smart"?
Oh wow... Well, within a week of getting one; I have configured it to run Raspbmc (now KODI). It happily stated serving as my media manager.

I thought about the experiment I did for the OpenHouse event. Though it was done in two days (and nights), demonstrating a simple concept of tracking, it became one of the best post in terms of web traffic. So, I thought; why not try it again. So, I went and bought Remote Control Car (8$ around) from a local shop. Not to fry my RPI GPIO, I found a motor driver from FabToLab. Last weekend, I could finish the first set of code to control the GPIO and in the first run itself, worked as expected.


  1. Opened up the remote (instead of car in the previous experiment)
  2. Removed the 4 Push Buttons underneath the joystick and soldered 4 Pins which were connected to RPI through the motor driver. Thanks to Jeshwanth for doing it for me.
  3. Used rpi 3.3V GPIO to power up the Remote. 


  1. Python GPIO Library to test the set-up. Left, Right and Accelerate were working
  2. Got back to my comfort zone language, Java with Pi4J
  3. Wrote the first set of code with "event loop". The events are the buttons and the joystick action is the duration of each event.

Code design: Thanks to Uncle Bob's talks

  1. Single Responsibility Principle and Separation of concerns
  2. Factory Pattern+ Singleton
  3. Program to Interface, prefer containment to derivation
  4. Use main program to "assemble" the pieces

High Level Design

  1. Interface: Drive
    •  drive (Activate forward/left/right)
    • release (turn off the pins which were kept on)
  2. DriveEvent (Drive,duration)
  3. Interface: AbstractDriveEventLoop
    • addEvent(DriveEvent)
    • fireEvent 


  1. DriveLeft, DriveRight, DriveStraight, NoDrive,StopCar implementing Drive
  2. DriveFactory : Which generates the drives
  3. DriveEventLoop using  BlockingQueue.
  4. ReadInstructions which can take a BufferedReader and fill the event loop

Pictures and Result

 Interested to peek in to the code?

 Next steps

  1. Add a close loop control system with OpenCV
  2.  Add unit testing code (yeah yeah!!!, I know, I am yet to reach the TDD level)

1 comment:

best essay service said...

I am very happy to see this type article because rarely people get the genuine information and article.Thank you so much.Waiting for new stuff.I am sure this article is helpful for all the people.