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

Arduino-Controlled DC Motor Driver for Multi-Directional Movement

View and Edit Project In Cirkit DesignerImage of Arduino-Controlled DC Motor Driver for Multi-Directional Movement

Circuit Documentation

Summary

This circuit is designed to control multiple DC motors using an Arduino UNO and L298N DC motor drivers. The L298N motor drivers allow for bidirectional control of the motors, enabling them to run forwards and backwards. The Arduino UNO serves as the central controller, sending signals to the motor drivers to manage the operation of the motors.

Component List

L298N DC Motor Driver


DC Motor


Arduino UNO


Wiring Details

L298N DC Motor Driver (Instance 1)


L298N DC Motor Driver (Instance 2)


Arduino UNO


Documented Code

void setup() {
  // Set control pins for the first driver as outputs
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);

  // Set control pins for the second driver as outputs
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
}

void loop() {
  // Run the first motor forward
  digitalWrite(2, HIGH);
  digitalWrite(3, LOW);
  analogWrite(9, 255); // Motor speed

  // Run the second motor backward
  digitalWrite(4, LOW);
  digitalWrite(5, HIGH);
  analogWrite(10, 255); // Motor speed

  // Run the third motor forward
  digitalWrite(6, HIGH);
  digitalWrite(7, LOW);
  analogWrite(12, 255); // Motor speed

  // Run the fourth motor backward
  digitalWrite(8, LOW);
  digitalWrite(11, HIGH);
  analogWrite(13, 255); // Motor speed

  delay(2000); // Run for 2 seconds

  // Stop the motors
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  digitalWrite(5, LOW);
  analogWrite(9, 0);
  analogWrite(10, 0);

  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
  digitalWrite(8, LOW);
  digitalWrite(11, LOW);
  analogWrite(12, 0);
  analogWrite(13, 0);

  delay(2000);
}

This documentation provides a comprehensive overview of the circuit, detailing the components used, their connections, and the code that controls the operation of the motors.