Lesson 20 DC Motor Control
Lesson 20 DC Motor Control
Introduction
In this lesson, you will learn how to control a small DC motor using a UNO R3
and transistor.
Hardware Required
1 * RexQualis UNO R3
1 * Breadboard
1 * L293D IC
5 * 9V 1A Adapter
Principle
The small DC motor is likely to use more power than a UNO R3 board digital
output can handle directly. If we tried to connect the motor straight to an UNO
R3 board pin, there is a good chance that it could damage the UNO R3 board.
So we use a power supply module provides power supply.
Product Specifications:
Output voltage:3.3V/5V
Size:2.1 in x 1.4 in
5V 3.3V
The left and right voltage output can be configured independently. To select the
output voltage, move jumper to the corresponding pins.
Note: power indicator LED and the breadboard power rails will not power on if
both jumpers are in the “OFF” position.
Important note:
Make sure that you align the module correctly on the breadboard. The
negative pin(-) on module lines up with the blue line(-) on breadboard and that
the positive pin(+) lines up with the red line(+).Failure to do so could result in
you accidently reversing the power to your project
L293D
This is a very practical chip that can independently control two DC motors. In
this experiment, just half of the chip is used. Since most pins on the right side
of the chip are used to control the second motor, they will not be used here.
L293D has two pins (Vcc1 and Vcc2) for power supply. Vcc2 is used to supply
power for the motor, while Vcc1 to supply for the chip. Since a small-sized DC
motor is used here, connect both pins to +5V. If you use a high power motor,
connect Vcc2 to an external power supply. At the same time, the GND of
L293D should be connected to that of the RuiiGuu Uno board.
DC Motor Specifications
Voltage:3-6V
Reference Current:0.35-0.4A
3V Rotating Speed:13000ROM
Code interpretation
void setup() {
pinMode(E1, OUTPUT);
pinMode(I1, OUTPUT);
pinMode(I2, OUTPUT);
void loop() {
digitalWrite(I1, HIGH);
digitalWrite(I2, LOW);
delay(10000);
// change direction
digitalWrite(E1, LOW);
delay(2000);
digitalWrite(I2, HIGH);
delay(10000);
Experimental Procedures
Schematic Diagram
Step 2: Open the code:DC_Motor_Control_Code
Step 3: Attach Arduino UNO R3 board to your computer via
USB cable and check that the 'Board Type' and 'Serial Port' are
set correctly.