RC Car Simulation with L298N Motor Driver and Joystick Control using Arduino (CirkitDesign Simulation)
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.
▶ Open Simulation in CirkitDesignWhat 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.
What You Need
Wiring Diagram
The diagram below shows all connections between the Arduino Uno, L298N motor driver, joystick module, two DC motors, and external battery.
Wiring Reference Tables
Joystick → Arduino
| Joystick Pin | Arduino Pin | Purpose |
|---|---|---|
| VCC | 5V | Power supply |
| GND | GND | Ground |
| VRx | A0 | Y-axis (forward/backward) |
| VRy | A1 | X-axis (left/right) |
L298N → Arduino
| L298N Pin | Arduino Pin | Purpose |
|---|---|---|
| IN1 | D8 | Left motor direction A |
| IN2 | D9 | Left motor direction B |
| IN3 | D10 | Right motor direction A |
| IN4 | D11 | Right motor direction B |
| ENA | D5 (PWM) | Left motor speed |
| ENB | D6 (PWM) | Right motor speed |
| GND | GND | Common ground |
L298N → Motors
| L298N Output | Connects To |
|---|---|
| OUT1 & OUT2 | Motor A (Left wheel) |
| OUT3 & OUT4 | Motor B (Right wheel) |
Building the Project
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.
Add Components
From the parts library, search and place: Arduino Uno, L298N Motor Driver, Joystick Module, 2× DC Motors, and a 9V battery.
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.
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.
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.
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.
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.
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.
/* * 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.
Test It in CirkitDesign
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)
.png)
Comments
Post a Comment