0% found this document useful (0 votes)
4 views11 pages

Microprocessor Lab Report

This lab report details the implementation of a motor control system using an Arduino, focusing on controlling a DC motor's speed and direction through PWM signals and a push switch. The experiment aims to familiarize students with Arduino functionalities and includes a comprehensive explanation of the circuit setup, code, and simulation results. The discussion highlights the practical applications of the system in automation and robotics, while also addressing challenges faced during the experiment.

Uploaded by

shihabhasan628
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views11 pages

Microprocessor Lab Report

This lab report details the implementation of a motor control system using an Arduino, focusing on controlling a DC motor's speed and direction through PWM signals and a push switch. The experiment aims to familiarize students with Arduino functionalities and includes a comprehensive explanation of the circuit setup, code, and simulation results. The discussion highlights the practical applications of the system in automation and robotics, while also addressing challenges faced during the experiment.

Uploaded by

shihabhasan628
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

AMERICAN INTERNATIONAL UNIVERSITY-

BANGLADESH
Faculty of Engineering

Lab Report
Experiment 09
Experiment Title: Implementation of a motor control system using Arduino: Digital input,
outputs, and PWM.

Date of Performance: 07 April 2026 Date of Submission: 28 April 2026


Course Title: Microprocessor and Embedded Systems Lab
Course Code: EEE4103 Section: I
Semester: Spring 2025-26 Degree Program: BSc in CSE
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan
Declaration and Statement of Authorship:
1. I/we hold a copy of this Assignment/Case Study, which can be produced if the original is lost/damaged.
2. This Assignment/Case Study is my/our original work; no part has been copied from any other student’s work or any other source except where
due acknowledgment is made.
3. No part of this Assignment/Case Study has been written for me/us by any other person except where such collaboration has been authorized.
by the concerned teacher and is acknowledged in the assignment.
4. I/we have not previously submitted or am submitting this work for any other course/unit.
5. This work may be reproduced, communicated, compared, and archived to detect plagiarism.
6. I/we permit a copy of my/our marked work to be retained by the Faculty Member for review by any internal/external examiners.
7. I/we understand that Plagiarism is the presentation of the work, idea, or creation of another person as though it is your own. It is a form of cheating and is a
very serious academic offense that may lead to expulsion from the University. Plagiarized material can be drawn from and presented in written, graphic, and
visual forms, including electronic data and oral presentations. Plagiarism occurs when the origin of the source is not appropriately cited.
8. I/we also understand that enabling plagiarism is the act of assisting or allowing another person to plagiarize or copy my/our work.

* Student(s) must complete all details except the faculty use part.
** Please submit all assignments to your course teacher or the office of the concerned teacher.

Group # 04

Sl No Name ID PROGRAM SIGNATURE


1 MUNNI AKTER 23-54938-3 BSc in CSE
2 SHADMAN SAKIB 23-54929-3 BSc in CSE
3 PRANTO KUMAR DAS 23-55449-3 BSc in CSE
4 MAHE ALAM MAHI 23-52683-2 BSc in CSE
5 MONTARIN RAHMAN JOUSTI 23-52687-2 BSc in CSE
6

Faculty use only


FACULTY COMMENTS
Marks Obtained

Total Marks
Table of Contents

Objectives 3
Equipment List 3
Circuit Diagram 3
Experimental Output Results (Color Photographs) 7
Simulation Output Results (Color Photographs) 10
Answers to the Questions in the Lab Manual 16
Discussion 16
References 16

Page 2 of 11
Objectives:

The objectives of this experiment are to

 Familiarize the students with the PWM signals generated by the Arduino.
 Control the speed of a DC motor using the PWM signals generated by the Arduino.
 Change the direction of rotation of a DC motor using the input push switch.

Equipment List:

 Arduino Uno Board


 L298N Driver
 12 V High Torque DC Motor with Fan Blades connected to it.
 Potentiometer, push switch, and a resistor of 10 k
 A DC Power Supply
 Breadboard
 Jumper Wires

Circuit Diagram:

Fig1: An Arduino microcontroller is controlling a DC motor’s speed through a dual H-bridge

Page 3 of 11
Fig2: Arduino board’s pin connections with a push button switch

Experimental Output Results:

Fig3: A motor control system

Page 4 of 11
Fig4: Serial monitor output clockwise (Low)
Simulation Output Results:

Fig10: Simulation output clockwise (Low)

Page 5 of 11
Explanation:

The simulation demonstrates a DC motor control system using an Arduino Uno, where the direction and speed
of the motor are controlled by a push button and a potentiometer, respectively. The push button is connected
to a digital input pin (pin 2) and is used to toggle the rotation direction of the motor—clockwise when the
button is pressed (LOW), and anticlockwise when released (HIGH). The potentiometer is connected to analog
input A0 and is used to vary the motor’s speed by providing an analog voltage, which the Arduino reads and
converts into a corresponding PWM (Pulse Width Modulation) signal sent to pin 10. This PWM signal
controls the speed of the motor through a motor driver module. Depending on the button state, the code sets
the appropriate HIGH/LOW logic on the motor driver input pins (pins 8 and 9) to determine the rotation
direction. Throughout the operation, real-time data such as the digital PWM value and the equivalent analog
voltage are sent to a virtual terminal in the Proteus simulation. The terminal clearly displays messages
indicating the current motor direction and voltage, confirming the successful implementation of both
directional and speed control in the simulation.

Code and Explanation:

int switchrotation = 2; // input pin to switch the direction of rotation


int in1 = 8; //Declaring where our module is wired
int in2 = 9;
int ConA = 10;// Don't forget this is a PWM DI/DO
int speed1;
void setup() {
[Link](9600);
pinMode(switchrotation, INPUT);

pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(ConA, OUTPUT);
}
void TurnMotorA1() { //A function to control the direction and speed in one direction
digitalWrite(in1, LOW); //Switch between these HIGH and LOW states to change direction
digitalWrite(in2, HIGH);
float analogvalue = analogRead(A0); // declaring and reading an analog voltage value from the pin
int PWMvalue = map(analogvalue, 0, 1023, 0, 255); // mapping the analog readings to change
// range from 0-1023 to 0-255 to divide the value by 4 to get a PWM value
analogWrite(ConA, PWMvalue);// To activate the DC motor
[Link](“The motor is running in the clockwise direction.”); // May need to change
[Link]("Digital Value = ");
[Link](PWMvalue); //print digital value on serial monitor
//convert digital value to analog voltage
float analogVoltage = (PWMvalue *5.00)/255.00;
[Link](" Analog Voltage = ");
[Link](analogVoltage);
}
void TurnMotorA2() { //A function to control the direction and speed in another direction
Page 6 of 11
digitalWrite(in1, HIGH); //Switch between these HIGH and LOW states to change direction
digitalWrite(in2, LOW);
float analogvalue = analogRead(A0); // declaring and reading an analog voltage value from the pin
int PWMvalue = map(analogvalue, 0, 1023, 0, 255); // mapping the analog readings to change
// range from 0-1023 to 0-255 to divide the value by 4 to get a PWM value
analogWrite(ConA, PWMvalue);// To activate the DC motor
[Link](“The motor is running in the anticlockwise direction.”); // May need to change
[Link]("Digital Value = ");
[Link](PWMvalue); //print digital value on serial monitor
//convert digital value to analog voltage
float analogVoltage = (PWMvalue *5.00)/255.00;
[Link](" Analog Voltage = ");
[Link](analogVoltage);
}
void loop() {
if (digitalRead(switchrotation) == LOW) {
TurnMotorA1(); // function that keeps looping to run the motor continuously.
// you can add another one to stop through the delay() function to run for a certain duration.
}
else if (digitalRead(switchrotation) == HIGH) {
TurnMotorA2();
}
}

Answers to the Questions in the Lab Manual:

Ans no 3:

ID: 23-54929-3

X Y - P Q A B C - Z
2 3 - 5 4 9 2 9 - 3

Arduino Program’s Code:

// Define pins
int in1 = 5; // From P
int in2 = 4; // From Q
int switchrotation = 9; // From A
int ConA = 3; // From B =2 (PWM pin) But 2 is not PWM port that’s why we choose 3
Page 7 of 11
// Setup function
void setup() {
[Link](9600);

pinMode(switchrotation, INPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(ConA, OUTPUT);
}

// Clockwise rotation
void TurnMotorA1() {
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);

float analogvalue = analogRead(A0);


int PWMvalue = map(analogvalue, 0, 1023, 0, 255);

analogWrite(ConA, PWMvalue);

[Link]("Motor running clockwise");


[Link]("Digital Value = ");
[Link](PWMvalue);

float analogVoltage = (PWMvalue * 5.0) / 255.0;


[Link](" Analog Voltage = ");
[Link](analogVoltage);
}

// Anticlockwise rotation
void TurnMotorA2() {
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);

float analogvalue = analogRead(A0);


int PWMvalue = map(analogvalue, 0, 1023, 0, 255);

analogWrite(ConA, PWMvalue);

[Link]("Motor running anticlockwise");


[Link]("Digital Value = ");
[Link](PWMvalue);

float analogVoltage = (PWMvalue * 5.0) / 255.0;


[Link](" Analog Voltage = ");
[Link](analogVoltage);
}
Page 8 of 11
// Main loop
void loop() {
if (digitalRead(switchrotation) == LOW) {
TurnMotorA1();
} else {
TurnMotorA2();
}
}

Simulation:

Fig16: Simulation Based on ID (Clockwise)


Fig17: Simulation Based on ID (AntiClockwise)

Fig18: Tinkercad Simulation (Clockwise)

Page 9 of 11
Simulation Methodology :
Explanation (Proteus Simulation):

This simulation demonstrates a DC motor control system using an Arduino board in the Proteus software
environment. The circuit integrates key components such as an Arduino Uno, an L298 motor driver module, a
DC motor, a potentiometer connected to analog pin A0, and a digital switch (push button) on pin 3, which
dictates the motor’s rotational direction. The code begins by initializing the necessary pins for motor control:
in1 and in2 for setting direction, ConA for speed control via PWM, and switchrotation for direction input. The
setup() function sets up the serial communication and defines the pin modes. Within the loop(), the Arduino
continuously reads the state of the switch: if the button is not pressed (LOW), the TurnMotorA1() function
runs, which sets the motor to rotate clockwise by enabling in2 and disabling in1, while adjusting the speed
using the potentiometer’s analog input. If the button is pressed (HIGH), the TurnMotorA2() function is
executed, causing the motor to rotate anticlockwise by enabling in1 and disabling in2, again with speed
controlled via PWM from the potentiometer. Both functions output the current PWM value and the equivalent
voltage to the serial monitor, which is visible in the simulation screenshots, confirming real-time feedback.
This setup is an effective demonstration of bidirectional motor control with variable speed, driven by analog
input and digital logic.

Explanation (TinkerCad Simulation):

This Tinkercad simulation illustrates a DC motor control system using an Arduino Uno and an L293D motor
driver IC. The setup allows for directional control and speed variation of the motor, similar to the Proteus
simulation. In the circuit, the Arduino is connected to the L293D driver chip via digital pins, which send
control signals to dictate the motor's rotation direction. A push button is included and connected to a digital
input pin on the Arduino; it acts as a switch that toggles the motor’s rotation between clockwise and
counterclockwise. The motor is connected to the output terminals of the L293D, which supplies the required
current and voltage

to the motor based on the signals from the Arduino. Power is distributed through the breadboard with clear
VCC and GND rails connected to the Arduino. The L293D is properly powered with Vcc1 (logic voltage)
from the Arduino's 5V and Vcc2 (motor supply) from the breadboard's power rail. This simulation, combined
with the previously provided Arduino code, demonstrates a practical implementation of H-bridge motor
control with direction switching via a button and speed control via analog input (e.g., potentiometer, although
not visibly present in this setup). It provides a hands-on approach to understanding motor control principles
using basic components in a virtual environment.

Discussion:

The Arduino-based motor control system demonstrates a practical and efficient method for controlling both
the direction and speed of a motor using simple hardware and software. Directional control is achieved
through digital input and output pins, while speed is finely tuned using Pulse Width Modulation (PWM).
Incorporating a potentiometer as an analog input adds flexibility, allowing for real-time speed adjustments.
This setup highlights the adaptability of Arduino for applications in automation and robotics. The experiment
also emphasizes the advantages of rapid prototyping and scalability in microcontroller-driven motor systems.
However, challenges such as analog signal noise and power dissipation in the motor driver were encountered,
underlining the need for careful circuit design and appropriate component choices to ensure reliable and
efficient performance.
Page 10 of 11
References:

[1] Arduino IDE, [Link] accessed on 2nd July 2023.


[2] [Link] snaget/editel?tenant=circuits,
accessed on 2nd July 2023.

Page 11 of 11

You might also like