Have you ever been fascinated by remote-controlled cars and wondered how they work? Or perhaps you’re curious about dipping your toes into the world of electronics and programming? Building your own Arduino-controlled RC car is an incredible project that combines fun, learning, and hands-on experience. Many beginners believe that electronics and coding are daunting subjects reserved for experts, but with Arduino, that couldn’t be further from the truth. If you’re a hobbyist, a car enthusiast, or simply someone who enjoys tinkering, this project is perfect for you. And if, like many, you dreamed of having an RC car as a child, now is the perfect time to turn that dream into reality, especially if you’ve started learning to code and have an Arduino kit at hand.
This guide will walk you through creating an Arduino-based RC car from scratch. No prior experience with programming, Arduino, or electronics is necessary. While some background in these areas might be helpful, the project is designed to be accessible to everyone. We’ll be using a power bank as our power source. Power banks are readily available, often more affordable than batteries, rechargeable, and many of us already own one. This project focuses on the fundamental principles of building such a car, using minimal materials and providing a detailed explanation of the code. The skills you learn here can be applied to a wide range of other exciting projects. So, let’s dive in and learn how to create your own Arduino Control Car Program and bring it to life!
As a hobbyist myself, I aimed to use readily available materials and avoid specialized tools like soldering irons as much as possible. We’ll repurpose common household electronic items, like a USB cable and a power bank, which you likely already have. Feel free to follow these instructions closely, but also don’t hesitate to get creative and adapt the project to your own resources and ideas. Here’s a list of everything you’ll need:
- Arduino UNO board
- Car chassis kit (including wheels and motors)
- Jumper wires (male-male and female-male)
- Electrical insulation tape
- Bluetooth module (HC-06 or HC-05)
- DC motor controller (L298N)
- Power Bank with 2 USB outputs
- Piezo buzzer
- Android mobile phone
- PC with Arduino IDE installed
- ArduCar – Arduino RC Car Bluetooth Controller App (or any compatible Bluetooth RC car control app)
Step 1: Chassis Assembly
The first step is to assemble the chassis of your RC car. Most chassis kits come with their own assembly instructions, but in case you need a little extra guidance, here’s a breakdown of the process:
- Start by gathering the main chassis frame, the small plastic motor brackets (four in total, two for each motor), screws, brass spacers, nuts, motors, a spare USB cable, and four jumper wires.
- Connect a jumper wire to each terminal of the DC motors. Soldering provides the most secure connection, but if you don’t have a soldering iron, you can carefully twist or “knot” the wires onto the motor pins to ensure a good temporary connection.
-
Take your old USB cable and cut off one end, leaving approximately 20 cm (about 8 inches) of cable length with the USB connector.
-
Carefully strip a few centimeters of the outer cable insulation to expose the wires inside. You should find 4 or 5 wires, but we are primarily interested in two: the GND (ground) wire, which is typically black, and the VCC or power wire, usually red. Strip about 2-4 cm of insulation from the ends of both the red and black wires. You can leave them as they are, or for a more robust connection, twist or solder these wires to longer, stronger jumper wires. This will make connecting them to the motor controller easier and more reliable.
-
Now, take the motors and mount them onto the chassis frame using the plastic brackets. Use screws and nuts to secure them in place. Pay attention to the orientation of the motors. Each motor usually has a small dot or mark on one side. Ensure that these dots face inwards, towards each other, when both motors are mounted on the chassis. This ensures they are aligned correctly for driving forward.
- Once the motors are securely mounted, it’s time to install the third, supporting nylon wheel. Look at the rear end of the chassis frame; you should see a set of four small holes arranged in a square pattern. Take the brass spacers and attach them to these holes using screws. Make sure the brass spacers are on the same side of the frame as the motors.
- Attach the nylon supporting wheel to the brass spacers using screws. This wheel provides stability and balance to the car.
- Now, install the drive wheels onto each motor shaft. Notice the shape inside the wheel hub; it’s designed to match the motor shaft for a secure fit. You might encounter some resistance when pushing the wheels onto the shafts. Be gentle but firm, applying even pressure until the wheels are fully seated.
- With the wheels on, you can now mount the Arduino UNO board and the DC motor controller onto the chassis frame. Use the remaining screws and nuts from the kit to secure them. I used three screws and nuts for this step. Where necessary, use electrical insulation tape to cover any exposed wires or connections to prevent shorts and ensure a cleaner setup.
Step 2: Wiring the Electronics
With the chassis assembled and the Arduino and motor controller mounted, it’s time for wiring. Get your jumper wires ready – both male-male and female-male types will be needed.
-
Connect the wires attached to the motors to the DC motor controller. The L298N motor controller has screw terminals for connecting motors. Let’s establish a convention: the pins closer to the edge of the board (away from the heatsink) are the “negative” or GND pins, and the pins closer to the heatsink are the “positive” pins. Connect the motor wires as follows:
- OUT1: Left motor (-) GND wire
- OUT2: Left motor (+) wire
- OUT3: Right motor (+) wire
- OUT4: Right motor (-) GND wire
Make sure the connections are secure, tightening the screws on the terminal block.
-
Now, connect the Arduino to the DC motor controller. We’ll use the L298N’s input pins labeled IN1, IN2, IN3, and IN4 to send control signals from the Arduino. The OUT1, OUT2, OUT3, and OUT4 terminals are for power to the motors, while the IN pins receive commands from the Arduino to control the motor direction and speed. You’ll likely need female-male jumper wires for these connections. If you only have male-male wires, you might need to carefully modify them or solder wires to create the necessary connections. Connect the pins as follows:
- IN1: Arduino Digital Pin 5
- IN2: Arduino Digital Pin 6
- IN3: Arduino Digital Pin 10
- IN4: Arduino Digital Pin 11
-
The Bluetooth module is crucial for wireless control. The HC-05 or HC-06 Bluetooth module typically has 4 pins, labeled: VCC (Power), GND (Ground), TXD (Transmit Data), and RXD (Receive Data). Again, female-male jumper wires will be helpful. Connect them as follows:
- VCC: Arduino 5V pin (Power)
- GND: Arduino GND pin (Ground)
- TXD: Arduino Digital Pin 0 (RXD – Receive Data)
- RXD: Arduino Digital Pin 1 (TXD – Transmit Data)
Notice that the TXD and RXD pins are cross-connected. This is because the TX (transmit) pin of one device needs to connect to the RX (receive) pin of the other for data communication.
-
The piezo buzzer will add sound effects to your RC car. It has two legs: a longer leg (Anode, +) and a shorter leg (Cathode, -). While it’s recommended to use a 330 Ohm resistor in series with the piezo buzzer to limit current and protect it, especially with Arduino’s 5V output, it can sometimes make the buzzer very quiet. For this project, we’ll connect it directly, but be mindful of potential long-term stress on the buzzer. Female-male jumper wires are useful here as well:
- Anode (+) (longer leg): Arduino Digital Pin 3
- Cathode (-) (shorter leg): Arduino GND pin (Ground)
-
Powering the circuit is the next step. Take the USB cable you prepared earlier. Connect the red wire (positive) and black wire (ground) to the DC motor controller’s power input terminals. These are usually labeled 12V and GND. Connect them as follows:
- Red wire (+): L298N 12V input
- Black wire (-): L298N GND input
-
Finally, connect the USB connector of the modified USB cable to one USB output port of your power bank. Use another USB cable to connect the Arduino UNO to the second USB output port of the power bank. This powers both the Arduino and the motor controller. Mount the power bank onto the car chassis using electrical tape or another secure method. Some power banks have a power button; make sure to turn it on to supply power to the circuit.
-
With all parts wired and connected, we’re almost ready to drive! The last steps involve uploading the control code to the Arduino and installing a control app on your mobile phone.
Step 3: Programming Your Arduino
Now that your RC car is assembled and wired, the exciting part begins: programming! You’ll need to upload code to the Arduino board to tell it how to control the motors based on commands from your mobile phone. For this, you’ll need the Arduino IDE (Integrated Development Environment) software installed on your computer. You can download it for free from the official Arduino website. Once installed, follow these steps:
- Open the Arduino IDE program. Go to the “Tools” menu in the top bar. Hover over “Board:” and select “Arduino Uno” from the list. This ensures the IDE knows you’re working with an Arduino Uno board.
- Next, under the “Tools” menu, find “Port:”. If you haven’t connected your Arduino to your computer yet, this option might be grayed out. Connect your Arduino Uno to your computer using a USB cable. The “Port:” option should become active. Select the correct COM port for your Arduino. It might be listed as something like “COM3”, “COM5”, etc. If you’re unsure, try different ports until the upload works.
Before uploading the code, remember this crucial step: disconnect the Bluetooth module’s TX and RX wires (connected to Arduino Digital pins 0 and 1) from the Arduino board. These pins are also used for USB communication when uploading code, and leaving the Bluetooth module connected can interfere with the upload process and cause errors. After uploading is complete, you’ll reconnect these wires.
You have two options for getting the code into the Arduino IDE:
- Download and Open: You can download the complete Arduino code file (if provided separately). In the Arduino IDE, go to “File” > “Open” and select the downloaded file.
- Copy and Paste: Alternatively, you can copy the code provided below. In the Arduino IDE, create a new sketch by going to “File” > “New”. Then, paste the code into the newly opened sketch window.
Once you have the code in the Arduino IDE, click the “Upload” button (the right-arrow icon) in the toolbar. Make sure your Arduino board is connected to your computer via USB and the correct port is selected. The IDE will compile the code and upload it to your Arduino. You’ll see messages in the console area at the bottom of the IDE, indicating the progress of the upload.
After the code is successfully uploaded, disconnect the USB cable from your computer. Reconnect the Bluetooth module’s TX and RX wires to Arduino Digital pins 0 and 1. Finally, connect the USB cable from the Arduino to your power bank to power up the car.
The last step to control your RC car is to install a Bluetooth RC car control application on your Android mobile phone. You can use the “ArduCar – Arduino RC Car Bluetooth Controller” app available on the Google Play Store, or any other compatible app that sends serial commands for RC car control.
Launch the app, connect to your Bluetooth module (you may need to pair your phone with the Bluetooth module first – usually, the default pairing code is 1234 or 0000), and you’re ready to drive!
Congratulations, you’ve built your own Arduino-controlled RC car! Have fun experimenting and driving it around. If you have any questions or suggestions, feel free to leave them in the comments below.
#define in1 5
#define in2 6
#define in3 10
#define in4 11
int state;
int piezo = 3;
void setup() {
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
pinMode(piezo,OUTPUT);
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
state = Serial.read();
Stop();
switch (state) {
case 'F': forward(); soundFX(3000.0,30+400*(1+sin(millis()/5000))); break;
case 'G': forwardleft(); soundFX(3000.0,60); break;
case 'D': forwardright(); soundFX(3000.0,60); break;
case 'N': backright(); soundFX(3000.0,30+100*(1+sin(millis()/2500))); break;
case 'C': backleft(); soundFX(3000.0,30+100*(1+sin(millis()/2500)));
soundFX(3000.0,30+100*(1+sin(millis()/2500)));
soundFX(3000.0,30+100*(1+sin(millis()/2500)));
soundFX(3000.0,30+100*(1+sin(millis()/2500)));
break;
case 'B': back(); soundFX(3000.0,30+200*(1+sin(millis()/2500)));
soundFX(3000.0,30+200*(1+sin(millis()/2500)));
soundFX(3000.0,30+200*(1+sin(millis()/2500)));
soundFX(3000.0,30+200*(1+sin(millis()/2500)));
break;
case 'L': left(); soundFX(3000.0,60);
soundFX(3000.0,60);
soundFX(3000.0,60);
soundFX(3000.0,60);
break;
case 'R': right(); soundFX(3000.0,60);
soundFX(3000.0,60);
soundFX(3000.0,60);
soundFX(3000.0,60);
break;
case 'H': soundFX(3000.0,30+200*(1+sin(millis()/2500)));
soundFX(3000.0,60);
soundFX(3000.0,30+200*(1+sin(millis()/2500)));
soundFX(3000.0,60);
}
}
}
void forward() {
analogWrite(in1, 255);
analogWrite(in3, 255);
}
void forwardleft() {
analogWrite(in1, 50);
analogWrite(in3, 255);
}
void forwardright() {
analogWrite(in1, 255);
analogWrite(in3, 50);
}
void back() {
analogWrite(in2, 255);
analogWrite(in4, 255);
}
void backright() {
analogWrite(in2, 50);
analogWrite(in4, 255);
}
void backleft() {
analogWrite(in2, 255);
analogWrite(in4, 50);
}
void left() {
analogWrite(in4, 255);
analogWrite(in1, 255);
}
void right() {
analogWrite(in3, 255);
analogWrite(in2, 255);
}
void Stop() {
analogWrite(in1, 0);
analogWrite(in2, 0);
analogWrite(in3, 0);
analogWrite(in4, 0);
}
void soundFX(float amplitude,float period){
int uDelay=2+amplitude+amplitude*sin(millis()/period);
for(int i=0;i<200;i++){
digitalWrite(piezo, HIGH);
delayMicroseconds(uDelay);
digitalWrite(piezo, LOW);
delayMicroseconds(uDelay);
}
}
Step 4: Arduino Code Explanation and Bluetooth Module Configuration (Optional)
For those eager to understand the inner workings of the arduino control car program, let’s delve into the code. Even if you’re new to programming, this explanation will help you grasp the basic concepts and logic behind controlling your RC car. The Arduino IDE uses a simplified version of C/C++, making it relatively easy to learn, even without prior programming experience.
Every Arduino program is built around two fundamental sections:
-
void setup() { }
: This section runs only once when the Arduino board starts. It’s used to initialize settings, such as configuring the function of each pin.In our code, the
setup()
function looks like this:void setup() { pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); pinMode(in3, OUTPUT); pinMode(in4, OUTPUT); pinMode(piezo,OUTPUT); Serial.begin(9600); }
-
pinMode(in1, OUTPUT);
ThepinMode()
function sets the mode of a specific Arduino pin.in1
is a name we’ve assigned to Arduino pin 5 (explained later).OUTPUT
means we are configuring this pin to send signals out from the Arduino to control another component (in this case, the motor controller). Similarly,pinMode(in2, OUTPUT);
,pinMode(in3, OUTPUT);
, andpinMode(in4, OUTPUT);
configure pins 6, 10, and 11 as outputs to control the motor driver.pinMode(piezo, OUTPUT);
sets pin 3 as output for the piezo buzzer. If we were connecting a sensor to read data into the Arduino, we would useINPUT
instead ofOUTPUT
. -
Serial.begin(9600);
Serial
communication is used to send and receive data over the serial port, which in our case, is used for Bluetooth communication. Remember the Bluetooth module connected to Digital pins 0 (RX) and 1 (TX)? This line initializes serial communication at a baud rate of 9600 bits per second. The baud rate determines the speed of data transfer. 9600 is a common and reliable baud rate for Bluetooth modules.
-
-
void loop() { }
: Theloop()
function is the heart of your Arduino program. Code within this section runs repeatedly, as long as the Arduino is powered on. This is where the main control logic of your RC car resides.Let’s break down the
loop()
function in our code:void loop() { if (Serial.available() > 0) { state = Serial.read(); Stop(); switch (state) { // ... (cases for different commands) ... } } }
-
if (Serial.available() > 0) { ... }
Thisif
statement checks if there is any data available to be read from the serial port (i.e., from the Bluetooth module).Serial.available()
returns the number of bytes of data waiting to be read. If it’s greater than 0, it means your phone app has sent a command. -
state = Serial.read();
If data is available,Serial.read()
reads the first byte of incoming serial data and assigns it to thestate
variable. Thestate
variable, declared as an integer at the beginning of the code, will store the command character sent from your Android app (like ‘F’ for forward, ‘B’ for backward, etc.). -
Stop();
This line calls a function namedStop()
. We’ll see its definition later in the code. It’s designed to immediately stop the car’s motors before executing a new command. This prevents commands from overlapping and ensures smoother control. -
switch (state) { ... }
Theswitch
statement is a control structure that allows you to execute different blocks of code based on the value of a variable (in this case,state
). Eachcase
within theswitch
corresponds to a possible value ofstate
(a command character sent from the app).-
case 'F': forward(); soundFX(3000.0,30+400*(1+sin(millis()/5000))); break;
Ifstate
is ‘F’ (meaning the app sent the “forward” command), theforward()
function is called to move the car forward, andsoundFX()
function is called to play a sound effect.break;
is crucial; it exits theswitch
statement after executing the code for the currentcase
. -
The other
case
statements ('G'
,'D'
,'N'
,'C'
,'B'
,'L'
,'R'
,'H'
) follow a similar pattern, each corresponding to a different command (forward-left, forward-right, back-right, back-left, back, left, right, and a special sound effect ‘H’) and calling corresponding motor control functions (forwardleft()
,forwardright()
,backright()
, etc.) and potentially different sound effects.
-
-
-
Variable and Pin Definitions: Before
void setup()
, you’ll find these lines:#define in1 5 #define in2 6 #define in3 10 #define in4 11 int state; int piezo = 3;
-
#define in1 5
The#define
directive is used to create symbolic constants. Here, we are definingin1
as a symbolic name for the number5
. Wheneverin1
is used in the code, the Arduino IDE will replace it with5
. We do this forin2
,in3
, andin4
as well, associating them with Arduino pins 6, 10, and 11 respectively. These names (in1
,in2
,in3
,in4
) correspond to the input pins of the L298N motor controller, making the code more readable and easier to understand. -
int state;
This line declares an integer variable namedstate
. This variable will store the command character received via Bluetooth. -
int piezo = 3;
This line declares an integer variable namedpiezo
and initializes it with the value3
. This variable represents the Arduino pin connected to the piezo buzzer (Digital pin 3).
-
-
Motor Control and Sound Effect Functions: At the end of the code, you’ll find the definitions for functions like
forward()
,back()
,left()
,right()
,Stop()
, andsoundFX()
. These functions are called within theloop()
function’sswitch
statement to perform specific actions.-
void forward() { analogWrite(in1, 255); analogWrite(in3, 255); }
Theforward()
function makes the car move forward.analogWrite()
is used to send a PWM (Pulse Width Modulation) signal to the specified pins.analogWrite(in1, 255)
andanalogWrite(in3, 255)
send a full power signal (value 255, representing 100% duty cycle) to the motor controller pinsin1
andin3
, which are connected to the left and right motors respectively, causing them to rotate forward at full speed. -
void Stop() { analogWrite(in1, 0); analogWrite(in2, 0); analogWrite(in3, 0); analogWrite(in4, 0); }
TheStop()
function halts the car.analogWrite(..., 0)
sends a zero power signal (0% duty cycle) to all motor control pins, effectively stopping both motors. -
Functions like
forwardleft()
,forwardright()
,back()
,backright()
,backleft()
,left()
,right()
are defined similarly, using different combinations ofanalogWrite()
calls with varying power levels (values from 0 to 255) on different motor control pins to achieve different movements (turning, moving backward, etc.). For example,forwardleft()
reduces power to the left motor (analogWrite(in1, 50)
) while keeping full power to the right motor (analogWrite(in3, 255)
), causing the car to turn left while moving forward. -
void soundFX(float amplitude, float period) { ... }
ThesoundFX()
function generates a sound using the piezo buzzer. It takesamplitude
andperiod
as parameters to control the characteristics of the sound. It usesdigitalWrite()
to rapidly turn the piezo buzzer pin HIGH and LOW, generating sound waves. The complex calculation inside this function (usingsin(millis()/period)
) creates a varying frequency sound effect, adding a fun element to the RC car. The code is adapted from Arduino forum discussions about generating SciFi sounds with piezo buzzers.
-
Bluetooth Configuration (Optional)
HC-05 and HC-06 Bluetooth modules typically come with default settings, such as a baud rate of 9600, a default name, and sometimes a pairing password. For basic use, the default settings are often sufficient. However, if you want to customize these settings (e.g., change the Bluetooth module’s name, password, or baud rate), you can configure them using Arduino code.
Configuring the Bluetooth module usually involves sending AT commands to it via serial communication. This process is more advanced and requires a separate Arduino sketch specifically for Bluetooth module configuration. You may also need to temporarily adjust the wiring of your Bluetooth module for configuration purposes and potentially use voltage dividers with resistors to safely interface the 5V Arduino with the 3.3V logic level of the Bluetooth module’s data pins.
Numerous online tutorials and guides are available that explain how to configure HC-05 and HC-06 Bluetooth modules using Arduino. Search online for “HC-05 Bluetooth configuration Arduino” or “HC-06 Bluetooth configuration Arduino” to find detailed instructions if you wish to explore Bluetooth module configuration further.
We encourage you to experiment with the code, modify it, add new features, or even create your own mobile control application. This project is a starting point, and there’s a vast world of possibilities to explore in Arduino robotics and arduino control car program development. Share your creations and modifications in the comments below – we’d love to see what you build!