Android Things: A Remote Controlled Car
Android Things: A Remote Controlled Car
You can put Android's foray into connected devices and IoT to good use. This project focuses on creating, configuring, and controlling a remote control car made of Lego.
Join the DZone community and get the full member experience.Join For Free
Being an Android Developer, Google’s announcement of Android Things immediately piqued my interest.
As all the others I started out with buying one of the developer kits and then making some lights blink. Nice. But, well, if I have to be honest with myself, that was fun but actually of only limited use. Then again, fun is why I started out coding, so maybe not so limited after all.
Still, as I nevertheless wanted to create something more useful, now came the hard part: What to actually create? What could keep me going?
Since my kids obviously play a huge role in my life, I used it to play “Happy birthday” and “Auld Lang Syne” on my son’s birthday (which incidentally is on January, 1st) next. Better, but given the dismal sound quality, still not good enough.
After some googling around, skimming makers books at the local library and looking at Adafruit’s (US), Pimoroni’s (UK), Kiwi Electronic’s (NL), and Flikto Elektronik’s (D) websites, I decided to do some kind of vehicle. I thought, "That’s something that also might get the attention of my kids" – and after showing them some pics on the web, they indeed agreed: That’s the thing to go forward with.
The first idea was to use a ready made kit. This kit would provide all the necessary hardware like motors, motor drivers, wheels and so on. The only exception would be the Raspberry Pi (the developer board I chose to buy) itself.
That’s nice enough and proved to be quite a good starting point. But then I saw more self-made ideas. Having to build more ourselves is much better suited for us as a family. Especially since it gives the kids much more space to contribute to the overall project. For some nice pics see this Google image search for “Lego car raspberry pi”.
This car with Lego looked pretty impressive. Since the kids love to build and rebuild stuff with Lego this project of a Lego™ chassis is the role-model for our project. The kids could build (and rebuild) the chassis. They could also help connect some parts of the electronics. My role would be limited to ordering (and paying for) the stuff, soldering a bit (I hate soldering and try to get around it as much as possible) and, obviously, coding the apps.
To quickly get a grasp of what the coding might involve, I still bought a complete kit (the STS-PI by Pimoroni) as some kind of MVP for our RC car. As you can see it’s a rather simple construction – which suited me for getting started.
But it was obvious from the beginning that this would only be a start to test out some stuff and that the real thing would come later.
In the following sections, I’m roughly outlining some thoughts about the project so far – and some of the decisions already made.
Battery or Cable
Actually, that’s no question. The raspberry will be mounted on the chassis and the car must function without being tethered to any power plug or – even worse – my developer laptop. So I’m going to use a battery. For the quick prototype, it will simply be a power bank. For the final thing, it’s going to be proper batteries that are powerful enough to power the more powerful motors of the final car as well as the Raspberry Pi.
Controlling the Car
First explorations revealed that both Bluetooth and Wi-Fi Peer to Peer are not available on Android Things, yet. I very much hope they will be supported soon!
Building a proper radio controller is beyond my beginner’s grasp of hardware related stuff – and it surely doesn’t follow the minimum viable product approach. My kids (and I!) want to see a car going – no need to wait needlessly long
Thus I am going to use Wifi where both the car and the remote controller handheld are in the same network. But if I am going to use DNS-SD I have not yet decided – nor do I know if this works on Android Things.
Since I might eventually change to some kind of radio controller, the app must be flexible enough to accommodate for this change.
Abstracting the Car
I already mentioned that I have a kit for quickly getting to first results and that we later on want to built a car with Lego. Not sure how much they will differ in the end, but it’s very likely that they will have differing characteristics. My remote control shouldn’t need to know about this – and ideally most of the app on the car neither.
Abstracting the Device
Android Things runs on multiple devices. There are three developer kits already available and two currently listed as coming soon. And I expect more to come. Even though I currently only own two Raspberry Pi boards, I want this project to be agnostic to the actual device the car is running on. Thus I will also abstract away some of the Android Things characteristics.
We have two kids and thus have to have two vehicles (or suffer endless bickering). That one’s easy: We will have the Pimoroni kit and the self-built one.
For the same reason, both cars must be usable at the same time. Which has some ramifications for the apps. The remote controls must be able to steer both cars. But of course only one at a time. Maybe we even need some parental mode to prevent the kids switching cars on their own and thereby annoying the other one. You have no idea how big a role conflict prevention plays in my daily family life
To start with, these are the project’s requirements. They will evolve and be adapted while going along and I expect more to be appended. But for now those are the basics:
- The system must support multiple cars
- The system must support multiple Android handhelds as remote controls
- The system must support different Android Things devices to be used within the vehicles
The first item going to be implemented will be to make the Pimoroni kit move properly – while keeping the abstractions in mind. At first it will just run a preprogrammed sequence to showcase that the car can go forward, backward and can turn around.
I haven’t decided yet about the next steps after this, but most likely I will first create the remote control before building the second car. But with the kids acting like product owners, you never know.
By the way, some preparations have already been done: We ordered a motor driver. We ordered some wheels and motors and I even soldered some wires onto them. We ordered some Lego bricks with holes to fasten the motor properly. Alas, those Lego parts are not here, yet. Which means we cannot start constructing the chassis
But apart from that, not much has been done yet. I guess it’s about time to get my hands dirty and to start coding.
Stay tuned! You will hear about our progress.
And in the meantime: Keep coding! Keep tinkering!
Published at DZone with permission of Wolfram Rittmeyer , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.