Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Controlled Dual-Motor Car with Joystick and L298N Driver

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Dual-Motor Car with Joystick and L298N Driver

Circuit Documentation

Summary

This circuit is designed to control a car using an Arduino UNO microcontroller and a dual-axis joystick module (KY-023) for user input. The Arduino UNO reads the joystick's position and sends commands to an L298N DC motor driver, which in turn controls two yellow hobby gear motors. The motors enable the car to move forward, backward, turn left, and turn right. The circuit is powered by the Arduino UNO, which also provides power to the joystick and motor driver.

Component List

Arduino UNO

Motor Amarillo Motorreductor Hobby (x2)

L298N DC Motor Driver

KY-023 Dual Axis Joystick Module

Wiring Details

Arduino UNO

Motor Amarillo Motorreductor Hobby

L298N DC Motor Driver

KY-023 Dual Axis Joystick Module

Documented Code

/*
 * Arduino Sketch for controlling a car using Bluetooth technology.
 * This code reads commands from the Serial input (Bluetooth module) and
 * controls the car's movement accordingly. The car can move forward,
 * backward, turn left, turn right, and stop based on the received commands.
 */

int Input_Pin_4 = 4; // Connected to IN4 on L298N
int Input_Pin_3 = 5; // Connected to IN3 on L298N
int Input_Pin_2 = 6; // Connected to IN2 on L298N
int Input_Pin_1 = 7; // Connected to IN1 on L298N
char Value;

void setup() {
  pinMode(Input_Pin_4, OUTPUT);  // Digital pin 4
  pinMode(Input_Pin_3, OUTPUT);  // Digital pin 5
  pinMode(Input_Pin_2, OUTPUT);  // Digital pin 6
  pinMode(Input_Pin_1, OUTPUT);  // Digital pin 7
  Serial.begin(9600);
}

void loop() {
  while (Serial.available() > 0) {
    Value = Serial.read();
    Serial.println(Value);
  }
  if (Value == 'F') {
    // Move Forward
    digitalWrite(Input_Pin_1, HIGH);
    digitalWrite(Input_Pin_2, LOW);
    digitalWrite(Input_Pin_3, HIGH);
    digitalWrite(Input_Pin_4, LOW);
  } else if (Value == 'B') {
    // Move Backward
    digitalWrite(Input_Pin_1, LOW);
    digitalWrite(Input_Pin_2, HIGH);
    digitalWrite(Input_Pin_3, LOW);
    digitalWrite(Input_Pin_4, HIGH);
  } else if (Value == 'L') {
    // Turn Left
    digitalWrite(Input_Pin_1, LOW);
    digitalWrite(Input_Pin_2, LOW);
    digitalWrite(Input_Pin_3, HIGH);
    digitalWrite(Input_Pin_4, LOW);
  } else if (Value == 'R') {
    // Turn Right
    digitalWrite(Input_Pin_1, HIGH);
    digitalWrite(Input_Pin_2, LOW);
    digitalWrite(Input_Pin_3, LOW);
    digitalWrite(Input_Pin_4, LOW);
  } else if (Value == 'S') {
    // Stop
    digitalWrite(Input_Pin_1, LOW);
    digitalWrite(Input_Pin_2, LOW);
    digitalWrite(Input_Pin_3, LOW);
    digitalWrite(Input_Pin_4, LOW);
  }
}

This code is designed to be uploaded to the Arduino UNO microcontroller. It sets up the digital pins connected to the L298N motor driver as outputs and initializes serial communication. The loop function reads a character from the serial input and controls the motors' direction and speed accordingly.