Codey OnlineArduino & ESP32 component library › Left DC Motor
Left DC Motor
Actuators

Left DC Motor

A DC motor converts electrical power into mechanical rotation and is typically used as a left drive motor in mobile robots. It must be powered and controlled through a motor driver, connecting the motor terminals (often labeled M1 and M2) to the driver’s motor outputs, while the driver handles direction and speed control.

Width: 58.6 mm

Pinout — Left DC Motor

Pin Signal Description
M+ power Positive motor terminal
M- power Negative motor terminal

Example wiring diagram — Left DC Motor

From To Wire
board:5V x1:VCC red
board:GND x1:GND black
board:D5 x1:IN1 green
board:D6 x1:IN2 blue
x1:OUT1 x2:M+ purple
x1:OUT2 x2:- cyan

Example Arduino code — Left DC Motor

This example was written and compile-checked for the arduino-uno. Codey Online adapts it to any other supported board for you.

const int motorIn1 = 5;
const int motorIn2 = 6;

void setup() {
  pinMode(motorIn1, OUTPUT);
  pinMode(motorIn2, OUTPUT);
  Serial.begin(9600);
  Serial.println("Left DC motor demo starting...");
}

void driveForward(int speedValue) {
  analogWrite(motorIn1, speedValue);
  digitalWrite(motorIn2, LOW);
}

void driveReverse(int speedValue) {
  digitalWrite(motorIn1, LOW);
  analogWrite(motorIn2, speedValue);
}

void motorStop() {
  digitalWrite(motorIn1, LOW);
  digitalWrite(motorIn2, LOW);
}

void loop() {
  Serial.println("Forward");
  driveForward(200);
  delay(2000);

  Serial.println("Stop");
  motorStop();
  delay(1000);

  Serial.println("Reverse");
  driveReverse(200);
  delay(2000);

  Serial.println("Stop");
  motorStop();
  delay(1000);
}

Related components

A4988 Stepper Driver

A4988 Stepper Driver

DRV8825 Driver Board

DRV8825 Driver Board

L298N Motor Driver Board

L298N Motor Driver Board

NEMA17 Stepper Motor

NEMA17 Stepper Motor

Build your Arduino or ESP32 project with AI

Describe what you want to build. Codey Online writes the code, draws the wiring diagram, compiles it and flashes your board straight from the browser.

Start for free