I like to draw, code, and build stuff.

Driving an RC Car With Node.js

Here’s a video of an RC car I rigged that’s controlled using the raspberry pi’s GPIO headers.

I know JavaScript is a terrible language to write autonomous cars in - it’s single threaded and has a terrible timer. Your accuracy is limited to ms and even then it’s not precise because of the single threaded nature.

That said, I wrote a node.js raspberry pi gpio library (you can run “npm install gpio” to install) and wanted to use it. I was already planning to make an autonomous car from an existing RC car with my Arduino board and decided to throw a raspberry pi on it for kicks, and I wanted to prove that my node gpio package works.

The node-rc library I used in the video can be found here

I like that rpi [can] have an entire operating system and I can ssh into it. I have a wireless usb dongle set up on the Pi and I had this lying around. I might build the autonomous car using the rpi in C or python or something.


A few people have been asking about the RC car so here goes…

I connected the gpio headers directly to the chip on the car, not the remote (the rpi needs to be on the car so I can connect sensors to it later). You can’t connect it directly to the motor as many people on this board have said - the pi can’t produce a constant current to drive the motors.

The nice thing about working with an RC car is that the motor driver is built in for you. Google the RX-2B datasheet; I’ve taken apart 3 RC cars so far and they all use the same chip. In general, pin 2 is ground, 6 is right, 7 is left, 10 is reverse, and 11 is forward. Connect the Pi’s ground to pin 2, then whatever gpio header you want to the corresponding pin. Word of advice, some cars have bigger chips than others. The Targets near me sells New Bright and Jada (brand) RC cars; the New Bright ones had such a small chip that it was impossible to solder anything on. The Jada was much easier to solder but had a terrible set of wheels and turning mechanism. I actually replaced the whole board on my New Bright car with the one from Jada (just connect the right wires to the motor and it’s fine).

Note: you can remove the chip altogether and solder your wire directly into where the hole used to be, but this will disable the remote controller. If you choose to keep the chip, in your software, remember to change the direction to “in” before using the remote.