Datasheet

Watch the Back-EMF Pulse
Replace the diode with an LED. You’ll see it blink each time it “snubs” the coil voltage spike when it
turns off.
Controlling a Motor
In CIRC-03 we controlled a motor using a transistor. However if you want to control a larger motor a
relay is a good option. To do this simply remove the red LED, and connect the motor in its place
(remember to bypass the 560 Ohm resistor).
Controlling Motor Direction
A bit of a complicated improvement to finish. To control the direction of spin of
a DC motor we must be able to reverse the direction of current flow through it.
To do this manually we reverse the leads. To do it electrically we require
something called an h-bridge. This can be done using a DPDT relay to control
the motor's direction, wire up the following circuit. It looks complicated but can
be accomplished using only a few extra wires. Give it a try.
NOT WORKING? (3 things to try)
MAKING IT BETTER
CODE (no need to type everything in just click)
MORE, MORE, MORE:
No Clicking Sound
The transistor or coil portion of
the circuit isn't quite working.
Check the transistor is plugged
in the right way.
29
CIRC-11
File > 1.Basic > Blink
(example from the great arduino.cc site, check it out for other great ideas)
Examples >
/*
* Blink
*
* The basic Arduino example. Turns on an LED on for one second,
* then off for one second, and so on... We use pin 13 because,
* depending on your Arduino board, it has either a built-in LED
* or a built-in resistor so that you need only an LED.
*
* http://www.arduino.cc/en/Tutorial/Blink
*/
int ledPin = 2; // *********** CHANGE TO PIN 2 ************
void setup() // run once, when the sketch starts
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop() // run over and over again
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
More details, where to buy more parts, where to ask more questions:
http://ardx.org/CIRC11
Not Quite Working
The included relays are
designed to be soldered rather
than used in a breadboard. As
such you may need to press it
in to ensure it works (and it
may pop out occasionally).
Nothing Happens
The example code uses pin 13
and we have the relay
connected to pin 2. Make sure
you made this change in the
code.
Arduino
pin 2
resistor
(2.2kohm)
gnd
(ground) (-)
Collector
Emitter
Base
+5 volts
Transistor
P2N2222AG
coil
com
NC
NO
Diode
(flyback)