Objectives:
By the end of this session:
© S. Pithouse for use by Warwick Technology Volunteers
Page: 1
Arduino Uno
Breadboard
Jumper Wires
Motors are used in many devices, such as fans, remote control cars, planes and helicopters as well as in automatic doors, microwaves and other common objects.
Motors
The Arduino can not supply enough power to turn the motors, therefore, it tells the motor driver chip the speed of the motor, and the chip powers the motor Motor Driver Chip
© S. Pithouse for use by Warwick Technology Volunteers
Page: 2
1)
Insert the motor driver chip into the breadboard, make sure that the little ‘U’ shape is at the top as shown in the diagram. Connect the battery wires and a wire between GND and the chip.
2)
Connect the motor as shown in the diagram.
3)
Finally, connect a wire between the Pin 9 and the motor driver chip.
© S. Pithouse for use by Warwick Technology Volunteers
Page: 3
1)
Plug the USB cable into the Arduino and Computer, then open the Arduino
Program.
2)
The default program will look like this:
3)
You first need to tell the program that the motor wire is connected to pin
9, and that it is an output:
© S. Pithouse for use by Warwick Technology Volunteers
Page: 4
4)
Finally, tell the program what you would like the motor to do. In this case, the motor is an analogue output (speed can vary—isn’t just on and off).
5)
Upload the program by clicking on the upload button.
6)
Connect the battery to the connector and watch the motor, it should be spinning!
Try changing the number 100 to another number between 0 and 254 and see how the speed changes.
Also, connect the motor wires the other way around, notice what happens...
In real life, often 2 motors are used together, for example in electric cars, wheelchairs and robots. Therefore, the following steps will involve you adding a second motor.
© S. Pithouse for use by Warwick Technology Volunteers
Page: 5
7)
Connect another motor as shown in the diagram below. Then add the orange wire between the Arduino (pin 10) and the chip.
8)
You should see numbers appear in the window, turn the potentiometer and watch the values change. These numbers are being used to set the brightness of the LED.
© S. Pithouse for use by Warwick Technology Volunteers
Page: 6
9)
You need to tell the Arduino that the other motor is connected to pin 10, and that it is an output. Then finally you need to tell it to send the motor a value (between 0 and 254) to make the motor turn.
Extension task
Imagine that the motors are connected to wheels on a robot, make a program that would make the robot go straight, left, then right.
HINT: You will need to stop one motor to turn
© S. Pithouse for use by Warwick Technology Volunteers
Page: 7