![]() |
Wiring Lightswitch and LED (Driver Station
Any suggestions on how to wire 2 LED's to a light switch.
When its off its one LED When its on its the other LED http://www.chiefdelphi.com/forums/at...9&d=1234143000 is the diagram I planned on wiring the switches with |
Re: Wiring Lightswitch and LED (Driver Station
Connect the switch to one digital input port. Use the value of that port to switch the values of two digital output ports, which drive the LEDs.
If the value of the switch is 1, turn on digital output 1. If the value of the switch is 0, turn on digital output 2. The LEDs must have a resistor in series, use 680 Ohms or 470 Ohms. Connect the + side of the LED to +5 volts, connect the - side of the LED through the resistor to the digital output (which will act as a ground when switched on). (It is better to use the digital output as a ground than to supply power to the LED in this case) One other way is to use a double-pole double-throw switch. One pole (side) of the switch is for the digital input and wired like the top diagram, the other side is used for the LEDs and has +5 on the center terminal through a 470/680 Ohm resistor, the outside terminals on the switch have one LED each, the + side, and the other side of each LED connected to ground. This approach doesn't need any programming, but is harder to debug. Don |
Re: Wiring Lightswitch and LED (Driver Station
|
Re: Wiring Lightswitch and LED (Driver Station
Yes. But... maybe you should consider the LED you will use: Different colors need different voltages.
Calculate the resistor value by knowing Ohm's law (V=I*R), the voltage requirements of the LED and the current requirements of the LED (do NOT use the maximum LED current, use something quite a bit less. For example, 20 mA is a good value for almost all LEDs) and the voltage supply (from the driver station in this case). So, if your LED needs 2 volts, and you have a 5 volt source (the driver station), your resistor has to drop 3 volts. If your LED wants 20 mA, your resistor is (V/I = R, 3 / 0.02 = 150 Ohms, so anything from 150 to maybe 270 Ohms is OK (about a 2 to 1 ratio). So maybe my first answer, a 680 Ohm resistor, might be a little bit large (it is appropriate for a 12 volt source). It would be OK, but the LED might be dimmer than you prefer. You can also check if a 1/2 watt resistor is enough by using Watt's Law: P=I*V, so (3*0.02 = 0.06) or 60 milliwatts, so 1/2 watt is way overkill but that's never a problem. (It's bad when you try to dissipate 1 watt with a 1/2 weatt resistor - it 'overheats'.) |
| All times are GMT -5. The time now is 12:34. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi