10
while (digitalRead(3) == LOW)
;
Serial.println("The switch is now open!");
}
Watch the activity in the Serial Monitor window as you press and release the switch.
4 Controlling a Small DC Motor
The Arduino can control a small DC motor through a transistor switch. You will need a TIP120
transistor, a 1K resistor a 9V battery with battery snap and a motor.
The TIP120 pins look like this and on a schematic the pins are like this
Here is the schematic diagram for how to connect the motor
And here is a pictorial diagram for how to connect the components. The connections can be
soldered or they can be made through a solderless breadboard.