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.
Dissection
- Opened up the remote (instead of car in the previous experiment)
- 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.
- Used rpi 3.3V GPIO to power up the Remote.
Coding
- Python GPIO Library to test the set-up. Left, Right and Accelerate were working
- Got back to my comfort zone language, Java with Pi4J
- 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
- Single Responsibility Principle and Separation of concerns
- Factory Pattern+ Singleton
- Program to Interface, prefer containment to derivation
- Use main program to "assemble" the pieces
High Level Design
- Interface: Drive
- drive (Activate forward/left/right)
- release (turn off the pins which were kept on)
- DriveEvent (Drive,duration)
- Interface: AbstractDriveEventLoop
- addEvent(DriveEvent)
- fireEvent
Implementation
- DriveLeft, DriveRight, DriveStraight, NoDrive,StopCar implementing Drive
- DriveFactory : Which generates the drives
- DriveEventLoop using BlockingQueue.
- ReadInstructions which can take a BufferedReader and fill the event loop
Pictures and Result
Interested to peek in to the code?
Next steps
- Add a close loop control system with OpenCV
- Add unit testing code (yeah yeah!!!, I know, I am yet to reach the TDD level)

