2 years ago

Hack a remote control with Pi Zero

Control an Arduino-powered custom Lego car with a simple remote control and a Raspberry Pi Zero

Ever wanted to use a Raspberry Pi to remotely control an Arduino, but using something smaller and more portable than a keyboard? Here we’ll show you how to add a Pi Zero and wireless radio to a controller from an RC toy, turning it into a versatile and customisable project controller!

The full article can be found in The MagPi 46 and was written by James Lacey

You’ll need

Large RC car controller

Slice of Radio

XinoRF

USB power bank

Toggle switch

Hook-up wire

Micro USB cable

STEP-01 Prepare the controller

Open up the controller by removing any screws and plastic retention clips. Locate and remove the main PCB of the controller. You will see contacts on the PCB, which the joysticks or buttons on the controller touch to send signals to the integrated circuit (IC) on the board. Using a multimeter, you should be able to follow each contact to a pin on the main IC. On this controller there are four contacts, so four IC pins should be found and labelled.

STEP-02 Remove the main IC

The IC will probably be soldered to the PCB, so cut off all the legs with pliers and desolder all the legs from the board. Now is also the time to remove other large components from the PCB that may interfere with the placement of the Pi Zero. Remembering which pin hole connects to which IC, solder differently coloured wires to each hole and the other half of the contacts (which are usually connected via a common trace). It’s now time to prepare the Pi Zero.

STEP-03 Preparing the Raspberry Pi

Solder on only the first ten pins of a male GPIO header to the Pi Zero, so the serial pins are populated with connectors. Leave the rest of the GPIO holes unpopulated so you can solder on the pin connectors. Prepare a microSD card with Raspbian Jessie Lite on it, then connect to an HDMI monitor, mains power, and a keyboard to run raspi-config. Next, get the code from the GitHub repository and place it in your home directory.

STEP-04 Wiring up the Pi

If you are using the code without alterations, solder the contact for the forward position to GPIO 27, the backward contact to GPIO 22, the right contact to GPIO 23, and the left contact to GPIO 24. Connect the other half of each contact to a 3.3V pin. Bend over the wires so they are as flush with the PCB as possible, so you can still attach the Slice of Radio transceiver. Turn on the Pi and run the code; the HDMI monitor should display no signal, and the LEDs on the Slice of Radio should flash when you move the levers.

The Pi Zero fits neatly inside

The Pi Zero fits neatly inside

STEP-05 Running the code at boot

Edit the /boot/cmdline.txt file to include the line “init=/home/pi/filename-of-code.sh”. Verify that the code is correct and chmod +x the script. This is your last chance to change anything – the Pi will not boot to a terminal again without manual editing of cmdline.txt. Disconnect your HDMI monitor and keyboard, then reboot the Pi Zero. The LEDs on the Slice of Radio should flash to show that data is being transmitted.

STEP-06 Fitting the Pi in the controller

You may have to use a Dremel tool or wirecutters/pliers to remove parts of the internal structure of the controller, so that the Pi fits. We had to remove most of the battery compartment. After fitting, check that all the wires are still securely attached to the Pi and the controller. Test the controller again, ensuring the LEDs flash. You’ve completed most of the controller, but if you have sufficient space available, continue to the next step to get rid of that annoying power cable.

STEP-07 Fitting the battery

Prise the two halves of the power bank apart with a knife or screwdriver. You should see a cylindrical battery and a small PCB with a USB and micro USB socket. Remove these from the housing and desolder the large USB socket from the board. Using a multimeter, find and label the positive pad that the USB socket was soldered to. Cut off the large USB plug from the micro USB cable, then solder the red wire to the positive pad and the black wire to a terminal of the switch. Connect the other terminal to the negative pad on the PCB. Make a hole in the controller for the micro USB connector and glue it in place. You’re done!

Code listing