Main > Main Forum
LED control idea
Trimoor:
I have done this before. It works quite nicely, and you don't need any transistors of ICs.
Just a diode, resistor, and LED.
tetsujin:
Kremmit raises an excellent point: most microswitch controls have a normally-closed terminal in addition to the normally-open one. Connect the "common" terminal to ground, (as you probably will with most encoders) and "N.O." to the encoder input, and then you can use the third, "Normally Closed" terminal to create your LED circuit.
You can make the LED circuit completely passive - no gates or transistors or anything. Just connect the cathode side of each LED to ground, and to the NC terminal connect the anode side of the LED and also a resistor going to +5V. This is what will happen:
When the switch is not pressed, the "NC" terminal will be connected to ground. The pull-up resistor on that line will pass current straight to ground. Because both sides of the LED will be at zero volts, it will not light.
When the switch is pressed, the "NC" terminal will no longer have a direct connection to ground, so the current flowing from +5V through the pull-up resistor will flow through the LED, lighting it.
Of course, the +5V source may have to come from your encoder board for this to work... The +5V has to be +5V relative to the ground node, and since you're connecting the switch's common terminal to the encoder's ground line... well, there you go.
You needn't wait to have a physics class to learn this stuff - you probably have access to teachers and textbooks which can help you with this. You can also look for basic electronics tutorials on-line - though I'm a bit wary of that approach because there's so much bad information out there.
Here are some basics.
First of all, you can think of the entire circuit as a collection of "nodes". Any part of a device that has a lead sticking out, that's a circuit node. When two nodes are connected together with a wire, they're basically the same node. (Certainly for our purposes that's a fine assumption.) At any given time, a particular node will have a particular voltage level relative to the circuit's "ground" node.
Voltages are always measured relatively between two nodes. It's meaningless to say that a node has a particular voltage without making some kind of statement about what the measurement is taken relative to. Commonly it'll be taken relative to ground, but it's also helpful sometimes to measure two nodes relative to each other. This is useful when you're talking about two nodes on the same device: for instance, the voltage across the two nodes of a resistor can tell you how much current is passing through the resistor. (The greater the voltage difference, the greater the current...)
Current represents the flow-rate of electrons in the circuit. Current flows through wires, and between terminals of multi-terminal devices. The basic rule of current is called Kirchoff's Current Law, which states that the amount of current flowing into a node must equal the amount of current flowing out of a node.
Building simple circuits is sometimes a matter of balancing simple math problems, making sure the amount of current flowing through devices is great enough to operate them (when desired) but not so great that they burn out. Different devices have different relationships that determine how much current will pass based on how much voltage is across them. Resistors and light bulbs and such are generally linear, meaning that if you double the voltage drop, you roughly double the current. LEDs are different, however. They have a particular voltage operating range. If you exceed that, the current increases greatly. Double an LED's voltage and you'll likely burn it out rather quickly.
IMO understanding the basics of nodes, voltages, and currents is critically important in building circuits and understanding how they work. You can muddle through without it, lots of people do, but you'll fare better if you know the mechanics of the devices you're using.
I'm doing similar work for my cabinet, and this thread has raised some good points for me, too. In particular, the need for the LED driver's ground to match the game encoder's ground in order for the LED driver and game encoder to monitor the same signal from the controls was something I hadn't thought of. (If I have two USB devices doing the two jobs, the two grounds should be the same... probably both being connected to the shielding and, eventually, indirectly, to the computer's casing and the AC line ground... So maybe my design is OK... But what happens if I want to drive some stuff from a separate AC-DC adaptor? I figure it's best to give that one some extra thought.)
cholin:
See the problem with me is that I got an idea, but I dont have the knowledge of currents or how they are divided or any components! I forget what it's called but I think its called a transistor. Anyways, I saw one of these transistors in a circuit and I learned basically what it does. I figured, since my iPac will have an output for Keyboard lights, which is +5v, and a ground (-5v), I could just connect a simple circuit consisting of nothing more than some of these transistors and terminal strips. I know I may come off stupid trying to use the same idea, but just look at this and tell me whether or not it will work. Thanks to Kremmit for telling me how to post a picture! By the way, this was designed with a MOLEX in mind, so just pretend that isnt there. The gray circles are transistors that draw 5 volts if some is passed to it's base. Please keep in mind Im trying to keep this cheap, not blow any LEDs and well, yah. This would be alot easier if I knew that the iPac gave out so many volts at each connection...does anyone know? For example, how many volts does it put out on PLAYER 1 UP?
Trimoor:
What about my idea? No transistors, and it doesn't even need a SPDT switch.
Plus, I currently use it. It works.
It can even use independend power sources. I'm using a 3v battery pack with a keyboard encoder. Just tie the grounds together. The diode takes care of the rest.
Kremmit:
--- Quote from: ShinAce on February 14, 2005, 04:30:55 pm ---Kremmit, if the COM tab is connected to ground, that will work.
Ok, so now you've actually thought up a circuit. How are you going to switch between ALL ON and GAME?
--- End quote ---
"All On" is not exactly a toughie. Anybody that can't figure out how to turn on all of the LEDs at the same time needs to give up right here. You feed them power and hook it up to a switch, duh. Yes, there's a little more to it than that, but it's hardly the engineering challenge here.
--- Quote ---You should just learn some digital electronics. www.allaboutcircuits.com . That way, you could use my initial suggestions of logic gates.
--- End quote ---
Hey, I'm not the one trying to do this project. I don't care if it ends up using logic gates, or little tiny gnomes that flip a lightswitch every time the joystick moves. ;D
Like I said, I'm not the guru here- logic gates may be the best way to implement the circuit, no matter whether you connect to the NO or the NC tab. I was just trying to help anybody building this by pointing out they don't need to muck about with using the same part of their microswitch that's connected to their I-Pac. Sending 12v to your I-Pac by mistake would be, well, a mistake. :'(