I would like to know what the wiring convention is for driving an LED AND another device, like an optocoupkled relay, from the same output at the same time.
I don't think there's a "convention", but an optocoupler contains its own LED internally. You need a current limiting resistor for each one. The optocoupler has an LED forward voltage of 1.7 and you want somewhere up to 10mA of current. Consult the datasheet for the device for the amount of current you need for your circumstances. 5V - 1.7V = 3.3V. At 10mA, you'd need a 330 Ohm resistor.
The Stamp's I/O pin can handle up to 20mA, so your indicator LED can also use up to 10mA. The resistor value depends on the color of the LED. Red ones have a forward voltage of 1.7, orange and green ones roughly 2.1V, and blue and white ones roughly 3.3V. Again, consult the datasheet for the LED for the exact forward voltage at the current you're using. For a green LED, you'd have 5V - 2.1V = 2.9V. At 10mA, you'd need a 290 Ohm resistor. The closest standard value would be 300 Ohms.
The two resistor-LED pairs would be wired in parallel so the anode ends are connected to the I/O pin and the cathode ends to ground (Vss). You'd use a HIGH to turn them on.
Alternatively, you could wire the cathode ends to the I/O pin and the anode ends to +5V (Vdd). You'd use a LOW to turn them on in this case.
Post Edited (Mike Green) : 1/9/2009 2:50:49 PM GMT
Comments
The Stamp's I/O pin can handle up to 20mA, so your indicator LED can also use up to 10mA. The resistor value depends on the color of the LED. Red ones have a forward voltage of 1.7, orange and green ones roughly 2.1V, and blue and white ones roughly 3.3V. Again, consult the datasheet for the LED for the exact forward voltage at the current you're using. For a green LED, you'd have 5V - 2.1V = 2.9V. At 10mA, you'd need a 290 Ohm resistor. The closest standard value would be 300 Ohms.
The two resistor-LED pairs would be wired in parallel so the anode ends are connected to the I/O pin and the cathode ends to ground (Vss). You'd use a HIGH to turn them on.
Alternatively, you could wire the cathode ends to the I/O pin and the anode ends to +5V (Vdd). You'd use a LOW to turn them on in this case.
Post Edited (Mike Green) : 1/9/2009 2:50:49 PM GMT