RC Car Simulation with L298N Motor Driver and Joystick Control using Arduino (CirkitDesign Simulation)

RC Car with Arduino & L298N Motor Driver – Joystick Control | MakeMindz
Robotics Beginner Arduino CirkitDesign

RC Car Simulation with
Arduino & L298N
Motor Driver

Control a two-wheel DC motor car using an analog joystick and Arduino Uno — no hardware required. Simulate it live in CirkitDesign.

📅 February 2026 ⏱ 15 min read 🔧 Beginner–Intermediate 🖥️ Simulation Ready
▶ Open Simulation in CirkitDesign

What Does This Project Do?

This project simulates a joystick-controlled RC car using an Arduino Uno and the L298N dual H-bridge motor driver. Two DC motors — one for each wheel — are independently controlled to achieve forward, backward, left, and right movement.

The project is built and tested entirely in CirkitDesign, making it perfect for students and hobbyists who want to learn robotics without purchasing physical components first.

🕹️
Joystick Input
XY analog values 0–1023
🧠
Arduino Logic
Reads & decides direction
L298N Driver
H-bridge controls motors
⚙️
DC Motors
2-wheel differential drive

What You Need

🔵
Arduino Uno
Microcontroller
🔴
L298N Module
Motor Driver
⚙️
2× DC Motors
Left & Right wheels
🕹️
Joystick Module
XY analog axis
🔋
7–12V Battery
Motor power supply
🔌
Jumper Wires
Male–male & mixed
💡
Simulation: If using CirkitDesign, no physical parts are needed — all components are available in the virtual library.

 


Wiring Diagram

The diagram below shows all connections between the Arduino Uno, L298N motor driver, joystick module, two DC motors, and external battery.

ARDUINO UNO R3 USB D5(PWM) D6(PWM) D8 D9 D10 D11 A0 A1 5V GND JOYSTICK XY Module VCC GND VRx→A0 VRy→A1 L298N Motor Driver ENA ENB IN1 IN2 IN3 IN4 GND OUT1 OUT2 OUT3 OUT4 MOTOR A (Left) MOTOR B (Right) BATTERY 7V – 12V + Wire Legend Joystick → Arduino (analog) Arduino → L298N (PWM) Arduino → L298N (direction) L298N → Motors RC Car – Circuit Diagram Arduino Uno + L298N Motor Driver + Joystick
⚠️
Power Note: Use a separate 7–12V battery for the L298N motor power input. Never power motors directly from Arduino's 5V pin.

Wiring Reference Tables

Joystick → Arduino

Joystick PinArduino PinPurpose
VCC5VPower supply
GNDGNDGround
VRxA0Y-axis (forward/backward)
VRyA1X-axis (left/right)

L298N → Arduino

L298N PinArduino PinPurpose
IN1D8Left motor direction A
IN2D9Left motor direction B
IN3D10Right motor direction A
IN4D11Right motor direction B
ENAD5 (PWM)Left motor speed
ENBD6 (PWM)Right motor speed
GNDGNDCommon ground

L298N → Motors

L298N OutputConnects To
OUT1 & OUT2Motor A (Left wheel)
OUT3 & OUT4Motor B (Right wheel)

Building the Project

1

Open CirkitDesign Simulator

Go to app.cirkitdesign.com and create a new project. You can also import the diagram.json above to skip manual wiring.

2

Add Components

From the parts library, search and place: Arduino Uno, L298N Motor Driver, Joystick Module, 2× DC Motors, and a 9V battery.

3

Wire the Joystick

Connect the joystick: VCC → 5V, GND → GND, VRx → A0, VRy → A1. These are analog inputs, so no PWM pins are needed here.

4

Wire Arduino to L298N

Connect direction pins: D8→IN1, D9→IN2, D10→IN3, D11→IN4. Connect speed pins: D5→ENA, D6→ENB. Share GND between both boards.

5

Connect the Motors

Motor A (left wheel) → OUT1 & OUT2. Motor B (right wheel) → OUT3 & OUT4. Motor polarity determines forward direction — swap wires to reverse if needed.

6

Connect the Battery

Connect the 9V battery positive to the L298N 12V input terminal and negative to GND. This powers the motors independently from the Arduino's logic supply.

⚠️
Important: In simulation, set the battery voltage to 9V. The L298N's onboard 5V regulator can power the Arduino if jumper is set correctly.
7

Upload the Arduino Code

Copy the code from the section below. In CirkitDesign, click the Arduino component → Edit Code, paste it in, then click Compile & Run.

8

Test the Joystick

Start the simulation. Drag the joystick in CirkitDesign: up → motors go forward, down → reverse, left/right → turns. Center position stops motors.

Arduino Sketch

This sketch reads analog joystick values and drives the two DC motors accordingly via the L298N. Copy it into the Arduino IDE or directly into CirkitDesign.

Arduino C++
/*
 * RC Car – Arduino + L298N + Joystick Control
 * MakeMindz.com | February 2026
 *
 * Joystick Y-axis → Forward / Backward
 * Joystick X-axis → Left / Right turns
 */

// PWM speed control pins
const int ENA = 5;   // Left motor speed (PWM)
const int ENB = 6;   // Right motor speed (PWM)

// Direction control pins
const int IN1 = 8;   // Left motor – direction A
const int IN2 = 9;   // Left motor – direction B
const int IN3 = 10;  // Right motor – direction A
const int IN4 = 11;  // Right motor – direction B

// Joystick analog pins
const int VERT = A0;  // Y-axis (forward/backward)
const int HORZ = A1;  // X-axis (left/right)

void setup() {
  pinMode(ENA, OUTPUT);
  pinMode(ENB, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  stopMotors();  // Start with motors stopped
}

void loop() {
  int vertValue = analogRead(VERT);  // 0–1023
  int horzValue = analogRead(HORZ);  // 0–1023

  if (vertValue > 600) {
    moveForward();          // Joystick pushed up
  } else if (vertValue < 400) {
    moveBackward();         // Joystick pulled down
  } else if (horzValue > 600) {
    turnRight();            // Joystick pushed right
  } else if (horzValue < 400) {
    turnLeft();             // Joystick pushed left
  } else {
    stopMotors();           // Center position – stop
  }
}

// ── Movement Functions ──────────────────────

void moveForward() {
  digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW);
  analogWrite(ENA, 255);
  analogWrite(ENB, 255);
}

void moveBackward() {
  digitalWrite(IN1, LOW);  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, LOW);  digitalWrite(IN4, HIGH);
  analogWrite(ENA, 255);
  analogWrite(ENB, 255);
}

void turnRight() {
  // Left motor runs, right motor stops
  digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);  digitalWrite(IN4, LOW);
  analogWrite(ENA, 255);
  analogWrite(ENB, 0);
}

void turnLeft() {
  // Right motor runs, left motor stops
  digitalWrite(IN1, LOW);  digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW);
  analogWrite(ENA, 0);
  analogWrite(ENB, 255);
}

void stopMotors() {
  digitalWrite(IN1, LOW); digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW); digitalWrite(IN4, LOW);
  analogWrite(ENA, 0);
  analogWrite(ENB, 0);
}

How It Works

The system works through a simple control chain — joystick input gets interpreted by the Arduino, which then signals the L298N to drive the motors accordingly.

⬆️
Y > 600
Both motors forward at full speed
⬇️
Y < 400
Both motors reverse at full speed
➡️
X > 600
Left motor on, right motor off → turns right
⬅️
X < 400
Right motor on, left motor off → turns left
⏹️
Center
400–600 deadzone → both motors stop
🔄
PWM Speed
ENA/ENB set to 255 = 100% motor speed
🔬
The L298N H-bridge allows motor direction reversal by flipping the HIGH/LOW logic on each IN pair. IN1=HIGH, IN2=LOW spins one way; IN1=LOW, IN2=HIGH spins the other. ENA/ENB use PWM to control speed (0–255).

Test It in CirkitDesign

🖥️ Try the Simulation Free

CirkitDesign lets you test this circuit in your browser — no hardware, no soldering. Just import the JSON and hit simulate.

▶ Open CirkitDesign Simulator

What you can do in simulation:

  • 🕹️ Drag the joystick widget to control motor direction live
  • 👁️ Watch motor rotation direction change in real-time
  • 🐛 Use the Serial Monitor to debug analog readings
  • ⚡ Adjust PWM values (0–255) to test different speeds
  • 🔀 Experiment with turning logic (try tank-style turns)

What Can You Build Next?

🚗DIY RC Car
🤖Learning Robot
📡Bluetooth Car
🛑Obstacle Avoider
➡️Line Follower
📷Camera Bot
🚀
Upgrade Ideas: Add an HC-05 Bluetooth module to control via smartphone, add HC-SR04 ultrasonic sensor for auto obstacle avoidance, or replace the joystick with IR remote control.

Related Robotics Tutorials

Comments

try for free