Motor Driver Control

Z2M Part: EMA-00010-B

Control DC motors using L293D or L298N motor driver.

Circuit Diagram
Circuit diagram for Motor Driver Control
Wire Connections & Pin Configuration

Wire Color Connections:

Yellow/Orange → Pins 4–7 to L298N IN1–IN4
Red → 5V to L298N logic, 6–12V to motor supply
Black → GND to L298N GND

Pin Configuration:

Arduino Digital Pin 4 → L298N IN1 (Motor A Forward)
Arduino Digital Pin 5 → L298N IN2 (Motor A Backward)
Arduino Digital Pin 6 → L298N IN3 (Motor B Forward)
Arduino Digital Pin 7 → L298N IN4 (Motor B Backward)
Arduino 5V → L298N 5V/Logic supply
Arduino GND → L298N GND
External 6-12V → L298N 12V (motor power)
Motor A → L298N OUT1, OUT2
Motor B → L298N OUT3, OUT4
Arduino Code
Edit
// Define Motor Driver pins
const int A_1A = 4; // Left Motor Forward
const int A_1B = 5; // Left Motor Backward
const int B_1A = 6; // Right Motor Forward
const int B_1B = 7; // Right Motor Backward

void setup() {
  // Set all motor control pins as output
  pinMode(A_1A, OUTPUT);
  pinMode(A_1B, OUTPUT);
  pinMode(B_1A, OUTPUT);
  pinMode(B_1B, OUTPUT);
}

void loop() {
  // Move Forward
  digitalWrite(A_1A, HIGH);
  digitalWrite(A_1B, LOW);
  digitalWrite(B_1A, HIGH);
  digitalWrite(B_1B, LOW);
  delay(1000);

  // Move Backward
  digitalWrite(A_1A, LOW);
  digitalWrite(A_1B, HIGH);
  digitalWrite(B_1A, LOW);
  digitalWrite(B_1B, HIGH);
  delay(1000);
}

Instruction Details

Wiring: Connect L298N IN1 to Pin 4, IN2 to Pin 5, IN3 to Pin 6, IN4 to Pin 7. Connect 5V to logic, external 6–12V to motor supply. Connect Motor A to OUT1/OUT2, Motor B to OUT3/OUT4. Connect GND to Arduino GND.
Library: Not required (built-in).
Upload Code: Tools → Board → Arduino Uno. Tools → Port → select your COM port. Click Upload button.
View Output: Motors run in sequence (forward/backward). Adjust code for speed and direction.

How to Use

  1. Connect the required components as per the Pin Configuration above
  2. Open Arduino IDE and create a new sketch
  3. Copy and paste the code above
  4. Select your Arduino board and COM port from Tools menu
  5. Click the Upload button to upload the code to your Arduino
  6. Open Serial Monitor (if applicable) to see the output

Components Required

  • Arduino Uno
  • L298N or L293D Motor Driver Module
  • 2× DC Motors
  • External 6–12V Power Supply
  • Breadboard
  • Jumper Wires

Category: Motors & Servos