Project 1 - Controlling a DC motor using PWM and monitoring its Running status
Project:1
Overview
The system uses:
- L293D Motor Driver IC to control the direction and speed of the DC motor.
- Pulse Width Modulation (PWM) to control the motor speed.
- LCD Display to show the current status of the motor, including the direction and speed.
Goals
- Implement a system on a simulator to control a DC motor using an L293D motor driver.
- Control the motor speed using PWM.
- Display the running status of the motor on an LCD.
Key Highlights
- DC Motor Control:
- L293D allows controlling the direction and speed of the motor.
- Speed Control Using PWM:
- PWM signals adjust the input voltage, controlling the motor speed.
- LCD Status Display:
- Display motor speed and direction on the LCD.
Deliverables
- System implementation for controlling the DC motor using L293D.
- PWM control of motor speed.
- Real-time status of the motor shown on an LCD.
Expected Outcomes
- Control of the DC motor using the L293D motor driver and PWM.
- Monitoring and displaying the running status, including speed and direction, on the LCD.
Arduino Code Implementation
Components
- Arduino Board: For controlling and interfacing components.
- L293D Motor Driver IC: To drive the DC motor.
- DC Motor: To be controlled.
- LCD Display (16x2): To show the motor status.
- Potentiometer: To control motor speed.
Explanation
Motor Control:
- L293D Motor Driver:
- Pins
in1andin2are used to control the direction. - Pin
enAis used to control speed using PWM.
- Pins
- The motor is set to rotate in a specific direction (
in1HIGH,in2LOW) by default.
- L293D Motor Driver:
Speed Control:
- A potentiometer is used to control the speed.
- The
analogRead(potPin)reads the value from the potentiometer, andmap()scales this to a range suitable for PWM (0–255). - The
analogWrite(enA, motorSpeed)function sets the PWM value to control motor speed.
LCD Display:
- LiquidCrystal Library: Used to control the LCD.
- The LCD displays:
- The current speed of the motor as a percentage (
0-100%). - The direction of rotation (Clockwise in this example).
- The current speed of the motor as a percentage (
Control Logic:
- The motor speed is adjustable using the potentiometer.
- The direction is currently set to clockwise (
in1HIGH,in2LOW). This can be changed to counterclockwise by swapping these pin states (in1LOW,in2HIGH).