Built a RC car which can be controlled by touch using a cell phone.

Built with some electronics and programmed with just a few lines of JavaScript code.

How it was done: The hardware

I took an off-the-shelf RC car.

I removed the chassis and threw away the electronics board inside. I kept the bottom frame with the battery compartment, the motor and the wheels.

The steering was done by a second smaller motor, which could only be turned left and right, which resulted into that the wheels could only be turned 100% left and 100% right. So I removed that motor, too, and replaced it with a servo motor, which I could command to turn to an exact angle.

Next, I put several modules on a breadboard and put this on the frame.

The modules from top to bottom:

neonious one

The brain of the car. A great microcontroller board which can be programmed in JavaScript ES 6 or TypeScript with the full Node.JS API in an on-board IDE + debugger accessable with the webbrowser. For more information, visit the product page.

Dual Motor Driver

We are using the Polulu TB6612FNG breakout board. Fore more information, visit the product page.

A microcontroller board can control things with its pins, but these things must not draw much current. So, in case of motors, you need to add a motor driver board in-between which takes the commands from the microcontroller board and powers the motors with much more current. As a side effect, these boards allow you to turn a motor both ways.

We only need this board for the main motor and not for the steering, as servo motors already have the required driver right built in.

3.3 V + 5 V Step Up/Step Down boards

All modules we use need 3.3 V, with exception of the main motor, which uses the plain battery voltage, and the servo motor and the distance sensor, which both require 5 V.

The battery compartment holds 3 AA batteries which gives us 3.6 V – 4.5 V, so we cannot use the convenient voltage regulator of the neonious one which provides 3.3 V at 1000 mA, but needs between 4.5 V and 50 V as an input.

We use the Polulu 3.3 V and 5 V Step Up/Step Down boards which generate the fixed voltages from any input voltage between 2.7 V and 11.8 V. How convenient! Here is product page 1 and product page 2.

MPU-6050 gyroscope and accelerometer
u-blox NEO-6M GPS module
HC-SR04 distance sensors

These boards are actually not used in this project. I added them so I can write another blog entry later about the car driving autonomously around the neighborhood 🙂

Note that we already have ready libraries to use the GPS module (click here) and the distance sensor (click here) with low.js!

How it was done: The software

(1) Installed the ws package for WebSockets from the npm package manager built into the neonious one IDE and changed the settings to make the neonious one provide its own access point.

(2) Wrote a simple HTML page /www/index.html which reacts on touch and mouse events via JavaScript and sent the coordinates to the microcontroller with a WebSocket.

(3) Wrote a small program which runs on the microcontroller in the JavaScript file /src/index.js and provides a HTTP server which serves the HTML page and accepts WebSocket connections. It turns the main motor and the servo motor based on the coordinates it receives.

You can find the code here: https://github.com/neonious/lowjs_esp32_examples/tree/master/neonious_one/cellphone_controlled_rc_car

Leave a Reply

Your email address will not be published. Required fields are marked *