Challenge

Project 1 - Controlling a DC motor using PWM and monitoring its Running status

Here’s an Arduino-based simulation project to control a DC motor using an L293D motor driver and display its running status on an LCD.

---

Components Used:

Arduino Uno

L293D Motor Driver IC

16x2 LCD Display (I2C)

DC Motor

Push Buttons (for direction control)

Potentiometer (for speed control via PWM)

Power Supply (5V for logic, 12V for motor)

---

Code Implementation (Arduino)

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

#define ENA 9 // PWM pin for speed control

#define IN1 7 // Motor direction control

#define IN2 8 // Motor direction control

#define SPEED_CONTROL A0 // Potentiometer for speed adjustment

#define BUTTON_FWD 2 // Button for Forward

#define BUTTON_REV 3 // Button for Reverse

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {

pinMode(ENA, OUTPUT);

pinMode(IN1, OUTPUT);

pinMode(IN2, OUTPUT);

pinMode(SPEED_CONTROL, INPUT);

pinMode(BUTTON_FWD, INPUT_PULLUP);

pinMode(BUTTON_REV, INPUT_PULLUP);

lcd.init();

lcd.backlight();

lcd.setCursor(0, 0);

lcd.print("Motor Status:");

}

void loop() {

int speedValue = analogRead(SPEED_CONTROL); // Read potentiometer

int motorSpeed = map(speedValue, 0, 1023, 0, 255); // Convert to PWM range

if (digitalRead(BUTTON_FWD) == LOW) { // Forward Direction

digitalWrite(IN1, HIGH);

digitalWrite(IN2, LOW);

analogWrite(ENA, motorSpeed);

lcd.setCursor(0, 1);

lcd.print("Running: Forward ");

}

else if (digitalRead(BUTTON_REV) == LOW) { // Reverse Direction

digitalWrite(IN1, LOW);

digitalWrite(IN2, HIGH);

analogWrite(ENA, motorSpeed);

lcd.setCursor(0, 1);

lcd.print("Running: Reverse ");

}

else { // Stop the motor

digitalWrite(IN1, LOW);

digitalWrite(IN2, LOW);

analogWrite(ENA, 0);

lcd.setCursor(0, 1);

lcd.print("Motor: Stopped ");

}

delay(200);

}

---

Working Principle:

1. Motor Control

L293D is used to drive the DC motor.

Push buttons control the direction (Forward/Reverse).

Potentiometer adjusts motor speed using PWM.

2. LCD Display (I2C)

Shows current motor status (Stopped, Forward, Reverse).

3. PWM for Speed Control

Speed is varied using analogRead() from the potentiometer.

Converted to PWM signal (0-255) using analogWrite().

---

Deliverables:

Arduino code

Simulation in Proteus/TinkerCAD

Screenshots of LCD Display Outputs

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.