DC motor control using the L293D driver
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.

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.

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.
- Input voltage: 6.5–12 V
- Channels: Two independent channels
- Output voltage: 5 V or 3.3 V (selectable via jumpers: 0 V, 3.3 V, and 5 V)
- Maximum output current: 700 mA

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.

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

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

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
Make sure the external power supply module and the UNO R3 share a common ground.

How the circuit works
- When the sensor is submerged in water, the voltage on
pin Ssits between0 Vand1 V. - The UNO R3 analogue input reads that voltage and converts it into a digital value.
- The controller sends the PWM speed signal from
pin 5(orpin 6depending on wiring) topin 1(Enable) on the L293D driver. Pin 3andpin 4drive0 V(LOW) and5 V(HIGH) ontopin 2andpin 7of the motor driver to control direction.- Setting
pin 3toLOWandpin 4toHIGHspins the motor clockwise; reversing them spins it counter-clockwise. - In this demo, a small propeller on the DC motor blows air across the sensor to dry its surface, dropping the reading back down and stopping the motor.
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:
- A low-level water tank monitor with a solenoid top-up valve
- A rain detector wired to a motorised cover
- A basic leak detector
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.