We all love playing with RC toy cars. In this mini project I will show you how I created a simple RC toy car using bunch of wheels, motors, Arduino and nRF24L01.
We have two main components in any RC toy car namely Remote and Toy car. First we will create remote following that we will get into details of toy car.
Let's get started.
VideoHave a look at small comprehensive video describing all steps needed to create RC toy car. Video does not contain explanation on nRF's working which I will cover later.
Step 1: Remote's HardwareDescription: Remote allows player to control motion of toy car. My remote consist of three parts. 3.3V arduino pro mini, nRF24L01 and four push buttons. Arduino reads status of push buttons and transmit it using nRF24L01 connected on its SPI interface. Attached schematic shows connection between different parts of remote.
Components:- 3.3V arduino pro mini
- nRF24L01
- 4 push buttons
- Breadboard
- Male jumper wires
P.S. You will need FTDI USB to serial converter to program arduino pro mini.
Step 2: Remote's Software (Arduino Code)- Description: Like its hardware, remote's software also consist of three parts. Variable initialization, setup and loop.
- Variable initialization: Variable initialization includes specifying nRF's CE and CSN pin connection to Arduino along with address to be used by RF pipe formed between remote and toy car. Variable initialization also includes pin allocation for push buttons.
- Setup: In setup part, first we set pinMode of all push buttons to INPUT_PULLUP avoiding use of external resistors. Following pinMode is nRF radio's initialization.
- Loop: In loop part we read state of four pushbuttons, form an integer array and transmit it. This process repeats every 100ms (you can play with this number).
You can find code in code section.
Step 3: What Is NRF24L01?Description: Before we proceed to construction of toy car, lets talk about nRF24L01. It is a single chip transciver operation in 2.4GHz ISM band. Its supply voltage range from 1.9 to 3.6V. It consumes 11.3mA TX at 0dbm output power and 13.5mA RX at 2Mbps air data rate. It has four different transmission power settings and three different data rate settings. It uses SPI as communication interface to micro-controllers.
Breakout boards of nRF24L01 available in market contain 8 pins which segregates to 2 supply pins, 4 SPI pins, 1 chip enable and 1 interrupt pin as shown in attached image.
Also attaching a video on how you can create simple wireless link using nRF24L01.
Step 4: Toy Car's HardwareDescription: It's mechanical hardware consist of chassis made out of acrylic sheet and components assembled on it using M3 nut/bolts which includes a universal wheel, two plastic wheels and two geared DC motor. On electronic side we have 3.3V arduino pro mini, nRF24L01 and 3.3V regulator assembled on a PCB. To drive motors I am using L293D motor driver. Four AA cells make power source for toy car.
Components:
- DIY robot car chassis kit (this includes chassis, universal wheel, 2 plastic wheels and geared DC motors)
- M3 nuts and bolts
- 3.3V Arduino Pro Mini
- nRF24L01
- 3.3V regulator
- L293D motor driver module
- 4 AA cells and holder
Attached schematic shows all connections of toy car.
Let's take a look at L293D in next step.
Step 5: What Is L293D?Description: L293D is a quadruple half-H bridge driver. With proper data inputs each pair of drivers form a full-H bridge reversible drive suitable for motor applications. Pin diagram and functional table of L293D is attached in images, if EN is set to high output follows A pin. Functional block diagram is also attached. I used arrangement shown on left in toy car.
Step 6: Toy Car's SoftwareDescription: Like remote's arduino code, toy car's arduino code is also divided in three parts. Variable initialization, setup and loop.
- Variable Initialization: It includes nRF radio's setup identical to that of remote's radio. We also define arduino pins that connects to L293D motor driver in this segment.
- Setup: We set pins that connects to L293D as output followed by startup code for nRf24L01.
- Loop: We wait for availability of an integer array of size 4. On reception of this array we activate appropriate output pins depending on which button was pressed on remote.
Code is available in code section
That's it folks. Thanks for reading.
Let me now if you make a toy car of your own. Thanks again.
Comments