Last month I bought my first Arduino (actually a SparkFun RedBoard) and started playing around with Johnny-Five to control it via JavaScript. Since then, I’ve learned the basics of electronics, microcontrollers, and how Johnny-Five works. This weekend, I decided to buy a cheap RC car and see if I could hack the remote so I could control the car with my laptop.
I picked up a 1/24 scale New Bright 2014 Silverado for about $10 at Target. I chose this model because of the truck bed, so I would have a place to mount a microcontroller in case I decided to mod the car itself later. I also made sure to check what kind of batteries the remote used to make sure I could power it from my RedBoard. The remote uses two AAs, which is a total of 3 volts, so I figured the 3.3v power pin would be perfect. The car itself uses three AAs, which is a total of 4.5 volts, so if I do go down the road of hacking the car, using the 5v power pin should be fine.
The first thing I do whenever I dig into anything new is making sure that it works as I expect, so I can verify the behavior is the same after every step. After my kids played with the car for a bit, I knew everything was working, so it was time to start ripping things apart. The remote was just two pieces of plastic held together with two screws and a few plastic clips. As soon as I opened it, I found something unexpected. The joysticks were actually just two buttons for each axis, not a standard joystick with variable movement along the axes. In hindsight, this should have been obvious since the car didn’t have variable speed and the wheels snapped to a specific position when turning.
Now that I had the remote opened up, I had to get the circuit board out of the plastic. This was just a matter of pulling the battery leads straight out (while compressing the spring for the negative lead), then the circuit board came out very easily. I used some jumper wires to connect the 3.3v and GND pins from the Arduino to the battery contacts and pushed the forward button to make sure powering the remote was going to work. Once I had confirmed this worked, I hooked up two AAs so that I didn’t need to hold the wires in place as I did more testing. I then tested all four buttons just to make sure everything was still working.
At this point, my plan was to replace the buttons with some other component that I could control from the Arduino. I wasn’t really sure what I could use for the replacement though. My only thought was to use a relay, but then I decided to try to trace the circuit and see if there was another way to hook in without desoldering the buttons. I noticed that there were seemingly random solder points connected to each of the buttons (these turned out to be test points for the board), so I decided to try applying voltage to the solder point for the forward button. I already had a script open that blinks an LED every second, so I just used that for my testing, since it would toggle between a HIGH and LOW signal on the pin. I was happy to find out that this worked (once I remembered to connect the GND pin as well to complete the circuit). I then tested the other three solder points to make sure I had identified the correct point for each button.
I was finally ready to start modifying the board. I plugged in my soldering iron and cut six pieces of hookup wire (one for each button and two for power) while the iron was heating up. First up was desoldering the battery leads and adding the new wire leads to connect to the Arduino. Then I soldered a wire to each of the four solder points that corresponded to the four buttons. This is where I made my biggest mistake. I didn’t realize how stiff the hookup wire was and how fragile the solder points would be. When I tried to bend all the wires to plug into my breadboard, I ended up ripping out the wire for reverse. I had to solder the wire directly to the button at that point, but I learned a valuable lesson: bend the wires into their desired shape prior to soldering.
Now that the board was modified, I was ready to write a script to control the car. I decided to keep it simple and just use the arrow keys. Rather than having to hold down the keys, I made each action “sticky” so pressing up once would make the car go forward until you either pressed up again to stop it or pressed down to make it go in reverse. This worked pretty well, but it was very awkward for turning. Modifying the script to treat left and right as momentary actions would make it easier to control. My next step will probably be exposing the controls via a web server so my kids can control the car with their iPads. I never thought I’d be able to do that with a cheap off-the-shelf RC car and just an hour or two of tinkering. After just a few weeks of playing with Johnny-Five, it all seems so simple 🙂
var five = require("johnny-five"); var keypress = require("keypress"); keypress(process.stdin); process.stdin.resume(); var board = new five.Board(); board.on("ready", function() { var forward = new five.Led(13); var back = new five.Led(7); var left = new five.Led(12); var right = new five.Led(8); forward.on(); back.on(); left.on(); right.on(); process.stdin.on("keypress", function(_, key) { if (!key) { return; } switch (key.name) { case "up": forward.toggle(); back.on(); break; case "down": back.toggle(); forward.on(); break; case "left": left.toggle(); right.on(); break; case "right": right.toggle(); left.on(); break; case "c": if (key.ctrl) { process.exit(); } break; } }); this.repl.inject({ forward: forward, back: back, left: left, right: right }); });
Note: This script uses the keypress module.