Electronic – connect LEDs to USB keyboard – but they turn off after a second

keyboardledusb

I have a USB keyboard. As I work many times in the darkness, I put some LEDs into the keyboard case. I connected two pairs of yellow standard LEDs serially to the USB power lines (Vcc and ground, pin 1 and 4).

  ┌───⊳|───⊳|───┐
⊕─┤             ├─⊖
  └───⊳|───⊳|───┘

enter image description here

Now when I plugin the keyboard the four yellow LEDs turn on for a second, begin to flicker and then turn off. The keyboard works, though.

Standard LEDs need about 20 mA, if driven at the correct voltage (2.5 V might be a bit to much, that means they possibly need more than 20 mA). So for two pairs of serially connected LEDs that would only be 40 mA (or maybe a bit more due to overvoltage — at least I am sure that they need more than 1,67 V, because if I connect three LEDs serially to the USB, they don’t light up).

Why does that happen? Does the keyboard possibly tell the computer that it doesn’t need so much current/voltage and then the computer cuts it down?

Update

I have just soldered two cables to a USB powered USB hub and plugged them together with a similar four LED array into a breadboard. And what happened: The LEDs shine and stay lit up for ever. Then I connected my modified keyboard with its four new LEDs. The four LEDs in the breadboard stay lit, but the ones in the keyboard turn off again after a second. The keyboard works. I am using it to type this. How is that possible?

I have measured current and voltage for the LEDs on the breadboard: The USB hub provides a voltage of exactly 4.2 V! A current of 19 mA runs through the breadboard LEDs. A little bit low for two LEDs in parallel, but I don’t need a resistor.

Best Answer

Before USB enumerates the minimum current available is 100mA, you can find more information in the question How to get more than 100mA from a USB port? Because it's unlikely that the keyboard would require above 100mA I suspect it wouldn't be requesting more than 100mA so that will be the technical limit on how much you can draw when combined with the keyboard.

Without measuring the current used by the keyboard there's no sure way to know, but I'd hazard a guess at around 20mA. Although a USB compliant device shouldn't draw more than 100mA before it's been requested many PC USB controllers don't actually check / enforce that and often drawing 500mA doesn't cause a problem, even though it's not recommended.

I suspect your main problem is connecting the LEDs without a current limit resistor, that's almost always a bad idea because they like to driven by a current source rather than voltage. A yellow LED normally has a forward voltage drop of 2.1V so you'll have 4.2V for each pair of LEDs. Insert a 47 ohm resistor in series with each pair to limit the current to 20mA and I think it should solve your problem.

If you'd like to experiment with different LEDs and amounts of current there are a number of on-line LED calculators available. For example here's a LED series/parallel array wizard and the same site has a LED calculator for single LEDs.