Placeholder Image

Subtitles section Play video

  • Hi my name is Massimo Banzi and I like to make stuff.

  • Welcome to another Arduino tutorial video.

  • Today we are going to learn

  • how to use Arduino

  • to move things in the real world.

  • To do that, we need to learn

  • how to control a DC motor

  • using Arduino.

  • The DC motor is a simple

  • electro-mechanical device

  • that you can see here.

  • It is normally powered

  • by a 9V battery

  • We are going to build a circuit

  • that will let Arduino

  • turn on and off this motor.

  • And we will be using that

  • to control this colour wheel

  • that we have manufactured

  • using an old CD.

  • In the kit, you will find parts

  • in order to build the wheel adapter,

  • and you will find the paper

  • that you can glue on top of the CD.

  • There are some issues that we have to

  • take care of.

  • First of all the DC motor here

  • works normally at more than 5V,

  • which is the standard voltage

  • that Arduino operates at,

  • and it requires more current

  • than a single Arduino pin can provide.

  • Normally, we can just hook up

  • a regular LED to an Arduino pin,

  • because the amount of electrical current

  • that the LED needs in order to operate

  • is low enough that you can power it

  • with an Arduino pin.

  • But in the case of the DC motor,

  • the motor requires a current

  • which is much higher,

  • and we risk burning

  • the Arduino pin

  • if we try to hook it up directly.

  • There is also another issue

  • that we have to be aware of:

  • when you turn on and off

  • an electric motor

  • - when you turn it off actually -

  • it generates a spike of

  • negative voltage that can actually

  • go back into your equipment

  • and destroy some of the parts.

  • In order to solve this problem

  • we are going to use a new component

  • that we haven't used

  • in the other videos,

  • which is called 'mosfet transistor'

  • This is essentially

  • a switch that can be

  • turned on and off by

  • applying - or not -

  • a voltage to a certain pin

  • of the mosfet transistor.

  • The mosfet here has 3 pins

  • called source, drain, and gate.

  • The mosfet is essentially

  • an electronic switch that can be

  • turned on or off by

  • applying a voltage on a pin

  • called 'gate'.

  • So this mosfet transistor

  • has 3 pins called gate,

  • source and drain.

  • If you apply a voltage to the gate pin

  • it connects

  • the gate and the source together,

  • as if I was pressing

  • a button on a switch,

  • but this is all done electronically.

  • So I can use this

  • to connect the battery

  • to the motor,

  • and since the mosfet is sitting

  • in-between it basically

  • connects and disconnects

  • the motor from the battery

  • and I can control this

  • through software that I

  • write on the Arduino board.

  • When you turn off an electric motor,

  • it normally generates

  • a spike of negative voltage

  • that can destroy your equipment.

  • Even if the mosfet

  • is quite strong

  • it is still very sensitive

  • to these negatives spikes of voltage,

  • so we have added to the circuit

  • this "flywheel diode"

  • that conducts

  • only when the motor generates these

  • dangerous spikes of voltage

  • and protects the mosfet from burning.

  • So what the mosfet is doing for us:

  • it lets us control loads that are

  • larger than we can

  • normally manage with an Arduino pin;

  • it lets us operate at a voltage,

  • which is higher

  • than the standard Arduino voltage.

  • As I said,

  • Arduino operates at 5V

  • but the battery here is 9V.

  • Using the mosfet allows us

  • to switch on and off bigger loads

  • that operate at voltages

  • that are higher than the Arduino

  • standard operating voltage.

  • It protects us,

  • because if something happens,

  • the mosfet blows up at worst,

  • but using the diode the way we

  • hooked it up here we can protect

  • the mosfet and we have a fairly reliable

  • and robust way to turn on and off,

  • but even change the speed, if we want,

  • of this DC motor.

  • So let's look at how

  • we can build this circuit.

  • First of all we place the mosfet

  • on the breadboard

  • and then we connect the negative

  • ,the black wire,

  • of the motor right in the middle pin.

  • Then if you look at the mosfet

  • from the front,

  • where you can see the markings,

  • the pin on the left hand side

  • is the 'gate'.

  • We are going to wire it up

  • to pin number 9

  • on your Arduino.

  • The pin on the right hand side,

  • that's the ground.

  • We are going to

  • connect it with the jumper wire

  • to the ground rail

  • here on the breadboard.

  • Then we are going to connect

  • the ground from the battery

  • together with the ground

  • on the breadboard so that the battery

  • and the Arduino

  • have the ground in common.

  • This is a condition

  • needed so that

  • the power supply on the Arduino

  • and the battery have the ground in common

  • so that the voltages are all referring

  • to the same ground

  • and the circuit can operate properly.

  • So the circuit works like this.

  • We connect the 9v

  • coming from the battery

  • directly to the motor

  • and then from the motor

  • we connect the ground pin of the motor

  • to the mosfet

  • and then the mosfet connects to the

  • actual ground on the circuit.

  • So when the Arduino pin

  • turns on and off,

  • a 5v voltage

  • will be applied to the gate.

  • When the gate receives the voltage

  • from the Arduino pin, it will connect

  • the motor to ground

  • and the motor will start to spin.

  • When we remove the voltage