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

Arduino UNO Controlled Smart Car with L293D Motor Driver

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Smart Car with L293D Motor Driver

Circuit Documentation

Summary

This circuit is designed to control a smart car using an Arduino UNO microcontroller and an L293D motor driver. The car's movement can be controlled via serial communication, which is handled by the Arduino UNO. The circuit includes a power supply consisting of two 18650 Li-ion batteries, a 7805 voltage regulator, and a diode for reverse voltage protection. An electrolytic capacitor is used for voltage smoothing. The motors and wheels are driven by the L293D motor driver, which receives control signals from the Arduino UNO.

Component List

Arduino UNO

L293D Motor Driver

18650 Li-ion Battery x 2

7805 Voltage Regulator

Diode

Electrolytic Capacitor

Motor and Wheels (x2)

Wiring Details

Arduino UNO

L293D Motor Driver

18650 Li-ion Battery x 2

7805 Voltage Regulator

Diode

Electrolytic Capacitor

Motor and Wheels

Documented Code

/*
 * Smartcar with VC-02 AI Thinker
 * This Arduino sketch controls a smart car with motor drivers and a VC-02 module.
 * The car can be controlled via serial communication with the VC-02 module.
 */

// Pin definitions
const int motorEnable1 = 3;
const int motorInput1 = 4;
const int motorInput2 = 5;
const int motorEnable2 = 6;
const int motorInput3 = 7;
const int motorInput4 = 8;

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Initialize motor control pins
  pinMode(motorEnable1, OUTPUT);
  pinMode(motorInput1, OUTPUT);
  pinMode(motorInput2, OUTPUT);
  pinMode(motorEnable2, OUTPUT);
  pinMode(motorInput3, OUTPUT);
  pinMode(motorInput4, OUTPUT);

  // Set initial motor states
  digitalWrite(motorEnable1, LOW);
  digitalWrite(motorInput1, LOW);
  digitalWrite(motorInput2, LOW);
  digitalWrite(motorEnable2, LOW);
  digitalWrite(motorInput3, LOW);
  digitalWrite(motorInput4, LOW);
}

void loop() {
  // Check if data is available from VC-02 module
  if (Serial.available() > 0) {
    char command = Serial.read();
    handleCommand(command);
  }
}

void handleCommand(char command) {
  switch (command) {
    case 'F': // Move forward
      digitalWrite(motorEnable1, HIGH);
      digitalWrite(motorInput1, HIGH);
      digitalWrite(motorInput2, LOW);
      digitalWrite(motorEnable2, HIGH);
      digitalWrite(motorInput3, HIGH);
      digitalWrite(motorInput4, LOW);
      break;
    case 'B': // Move backward
      digitalWrite(motorEnable1, HIGH);
      digitalWrite(motorInput1, LOW);
      digitalWrite(motorInput2, HIGH);
      digitalWrite(motorEnable2, HIGH);
      digitalWrite(motorInput3, LOW);
      digitalWrite(motorInput4, HIGH);
      break;
    case 'L': // Turn left
      digitalWrite(motorEnable1, HIGH);
      digitalWrite(motorInput1, LOW);
      digitalWrite(motorInput2, HIGH);
      digitalWrite(motorEnable2, HIGH);
      digitalWrite(motorInput3, HIGH);
      digitalWrite(motorInput4, LOW);
      break;
    case 'R': // Turn right
      digitalWrite(motorEnable1, HIGH);
      digitalWrite(motorInput1, HIGH);
      digitalWrite(motorInput2, LOW);
      digitalWrite(motorEnable2, HIGH);
      digitalWrite(motorInput3, LOW);
      digitalWrite(motorInput4, HIGH);
      break;
    case 'S': // Stop
      digitalWrite(motorEnable1, LOW);
      digitalWrite(motorEnable2, LOW);
      break;
    default:
      // Unknown command
      break;
  }
}

This code is responsible for interpreting commands received via serial communication and controlling the motors accordingly. The commands 'F', 'B', 'L', 'R', and 'S' correspond to forward, backward, left, right, and stop movements of the smart car.