ver: nov-07
Here is how to connect a motor, a swtich and an LED to your Stamp and how to do some checking to make sure that everything worksThe strategy is to get the circuit going in stages, testing each part as you go. Once everything is wired correctly and can be either controlled or read by the computer correctly, then you can write the main program with confidence that all the pieces are working.
Here's a schematic that shows everything wired up. If using a membrane switch, here is one way to do the connections.
Follow the directions shown in the BASIC Stamp Guide ( PDF file) under the "Flashing an LED" section. Use this program to confirm that the LED works under computer control
high 0 : pause 1000 : low 0 : end
The LED should go on for 1 second. (The colons let you stack several code statements on one line. Swap in returns if you wish.)
Follow the directions shown in the BASIC Stamp Guide under "Reading a Switch". Use this program to confirm that the Stamp is reading the switch properly
check: debug dec in1 : pause 125 : goto check
The stream of 1's going across the debug window should change to 0's when you close the switch. If it doesn't, read the voltage at P1 with your DVM. It should be 5V with the switch open and 0V with the switch closed. If it isn't, remove the switch from the circuit and check for continuity with the beeper function of your DVM. The DVM should beep when the switch is closed (short circuit) and stay silent when open (open circuit). Sometimes switch contacts get dirty so if you aren't getting a short circuit, try wiggling the switch button while it is closed. The code assumes the switch is connected to Pin 1 on the stamp, but any pin can be used.
Use your TIP120 transistor and a separate 9V or 12V battery for this circuit. The motor can be either the gear motor or the small motor. For the small motor, you can use the 2N3904 transistor as the switch.
The TIP120 pins look like this

and here is the schematic diagram for how to connect the motor

"Px" is any I/O pin on your Stamp. For this exercise, use P2. Connect the minus of the battery to the emmiter of the transistor (E pin) and then also connect the emmiter of the transistor to ground (Vss) on the stamp board.
To check if things are working, take a jumper wire and short the collector to the emmiter pins of the transistor. The motor should turn on. Now, with the Stamp 9V battery in place, disconnect the 1K resistor from P2 and jumper over to +5V (Vdd). The motor should turn on. Put the resistor back into P2 and run the following program as a check
high 2 : pause 1000 : low 2 : end
The motor should turn on for 1 second.