~/nodetwelve.com$
34 notes · 6 topics
updated 2026-11-27

DC motor control using the L293D driver

· 4 min read

Project overview

This project is a simple DC motor control circuit built around an L293D motor driver and an UNO R3 board with an ATmega328P microcontroller. The UNO R3 reads input from a water level sensor and sends control signals to the L293D driver.

The motor itself runs on 5 V from a separate power supply module. Keeping the motor power separate from the UNO R3 is necessary because UNO R3 I/O pins are only rated for 40 mA maximum, whereas this DC motor draws roughly 100 mA.

DC motor control L293D schematic

Components used

Elegoo UNO R3

An open-source microcontroller board based on the ATmega328P. Its simple layout makes it practical for both hobby projects and quick prototyping. The UNO R3 provides 14 digital I/O pins (6 of which support PWM), 6 analogue inputs, a 16 MHz crystal oscillator, a USB port, a power jack, an ICSP header, and a reset button.

Elegoo UNO R3 microcontroller board

3.3 V / 5 V power supply module

An external breadboard power supply module for the DC motor. It is rated for up to 700 mA, which is more than enough for this setup.

Breadboard power supply module rated up to 700 mA

Caution

Do not power the motor directly from the UNO R3 pins, as they are not rated for loads above 40–50 mA. Even with smaller inductive loads, you still need back-EMF protection using a flyback diode across the motor terminals.

L293D motor driver

The L293D is a widely used 16-pin motor driver IC. A single chip can drive two DC motors at the same time with independent direction control. In this circuit, only one side of the chip is used for a single DC motor.

L293D motor driver internal block diagram

It handles motor direction switching via internal transistors and protects against induced voltage spikes when power is cut, thanks to its built-in flyback diodes.

1–6 V DC motor

5 V DC motor

A standard DC motor that runs comfortably on a 5 V DC supply:

Water level sensor

Water level sensor module

A basic water level sensor drawing about 20 mA, well within the UNO R3's limits:

Breadboard

A breadboard holds the L293D chip and power supply module so you can wire and test the prototype without soldering.

Breadboard wiring diagram

Info

Make sure the external power supply module and the UNO R3 share a common ground.

DC motor control breadboard wiring diagram

How the circuit works

Arduino sketch

int speedPin = 5;
int directionPin1 = 4;
int directionPin2 = 3;
int motorSpeed = 255; // 0 - 255 (100-255)
int waterValue = 0;
const int waterSensor = A0;

void setup() {
  pinMode(speedPin, OUTPUT);
  pinMode(directionPin1, OUTPUT);
  pinMode(directionPin2, OUTPUT);
  pinMode(waterSensor, INPUT);
  Serial.begin(9600);
}

void loop() {
  waterValue = analogRead(waterSensor);
  Serial.println(waterValue);
  if (waterValue > 10) {
    motorSpeed = 255;
  } else {
    motorSpeed = 0;
  }
  digitalWrite(directionPin1, LOW);
  digitalWrite(directionPin2, HIGH);
  analogWrite(speedPin, motorSpeed);
}

Demonstration

Here is a short demo of the circuit in action. The same control pattern can be adapted for setups like:

Measurements

When the sensor reading rises above 10, pin 5 outputs a PWM value of 255, running the motor at full speed. Under load, the DC motor draws around 102 mA, and the voltage drop across the water sensor is roughly 0.25 V.