Labsheet 4 IntroMecha 2 1
Labsheet 4 IntroMecha 2 1
ENGINEERING TECHNOLOGY
INTRODUCTION TO MECHATRONICS
(BMT 2112)
LAB 4
SIMULATION OF ARDUINO IN PROTEUS:
CONTROLLING DC MOTOR
2.0 THEORY
The lab deals with one type of motor which is DC motor and how they can be operated
with Arduino. There are many things that can be done using motors. We can make a
mobile car move, make a robot turn and others. If the motor is small enough, it can be
directly connected to the Arduino pin and simply turning the pin to High or Low will
control the motor. However, the DC motor that usually used are operated using high
voltage and it could kill the digital pin thus probably burn the Arduino. The solutions
available are to use the transistors or the H-Bridge L293D driver. In this lab, we will
explore using the L293D driver and configure the program to control the direction and
speed of the DC motor.
Figure 1
Figure 2
d) Place the dc motor next to L293D. Connect one terminal of the dc motor to pin
OUT1, and connect another terminal to pin OUT2. Refer to Figure 3.
Figure 3
f) Save the program with appropriate name and compile the program.
g) Copy the required hex file program and paste it inside the Proteus software.
h) Run the simulation and observe the dc motor direction.
i) Stop the simulation. Type the following program. The program just an addition of
codes from the previous program:
a) Use the same circuit as in Figure 3 but this time connect EN1 pin of L293D to pin
5 of the Arduino. Refer to Figure 4.
Figure 4
Table B
Value at EN1 pin DC motor speed
(Slow / Fast)
60 SLOW
255 FAST
4.3 Exercise
With the knowledge you have obtained from previous lab and in this lab, produce the
circuit and the program to control the following dc motor application:
• Pressing pushbutton A will rotate the dc motor at slow speed (60)
• Pressing pushbutton B will rotate the dc motor at medium speed (130)
• Pressing pushbutton C will rotate the dc motor at full speed (255)
• The dc motor must be stop first before changing to another speed by
pressing pushbutton D
In 4.2, to determine the speed of motor, I’ve connect between driver and Arduino from
EN 1 to pin 5. The range speed is 0 to 255. For the first spin the speed is 60 and its
code like ‘ analogWrite (EN 1,60). For second one the speed goes from 60 to
maximum which 255 and its code like ‘ analogWrite (EN 1,255)
In exercise 4.3, to control the direction and the speed, I’ve used 4 push button and its
b1, b2, b3, and b4. For b1 I’ve code it to rotate the dc motor at slow speed (60). For b2
I’ve code it to rotate the dc motor at medium speed (130). For b3 I’ve code it to rotate
the dc motor at full speed (255). For b1 I’ve code it for the dc motor must be stop first
before changing to another speed.
6.0 CONCLUSION
The lab deals with one type of motor which is DC motor and how they can be operated
with Arduino. There are many things that can be done using motors. We can make a
mobile car move, make a robot turn and others. If the motor is small enough, it can be
directly connected to the Arduino pin and simply turning the pin to High or Low will
control the motor. However, the DC motor that usually used are operated using high
voltage and it could kill the digital pin thus probably burn the Arduino. The solutions
available are to use the transistors or the H-Bridge L293D driver. In this lab, we will
explore using the L293D driver and configure the program to control the direction and
speed of the DC motor.