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.