11
Pin 2 can be any digital I/O pin on your Arduino. Connect the minus of the battery to the emitter
of the transistor (E pin) and also connect the emitter of the transistor to Gnd on the Arduino
board.
To check if things are working, take a jumper wire and short the collector to the emitter pins of
the transistor. The motor should turn on. Next, disconnect the 1K resistor from pin 2 and jumper
it to +5V. The motor should turn on. Put the resistor back into pin 2 and run the following test
program:
void setup()
{
pinMode(2,OUTPUT);
digitalWrite(2,HIGH);
delay(1000);
digitalWrite(2,LOW);
}
void loop()
{}
The motor should turn on for 1 second.
Pin 2
Gnd
Pin 2Pin 2
Gnd
Pin 2