A transistor is basically a switch that can disconnect ground or 5V. There are transistors of all sorts, and some can switch truly huge loads. 50 LEDs is no big deal.
So, the question then is this: Can a single 2N3904 switch 50 LEDs?
To answer that, we'd need to know first what kind of LEDs. But let's assume you are using the usual nothing-special variety. A reasonable estimate of the maximum current of these is \$20mA\$. If you have 50, then the maximum current is \$20mA \cdot 50 = 1000mA \$. Looking at the datasheet I see the maximum collector current for 2N3904 is \$ 200 mA \$. So the answer is no: you can not switch 50 LEDs with one 2N3904.
I suppose you have several options:
- use multiple 2N3904
- use fewer LEDs
- use the same LEDs, but drive them with less current
- use a bigger transistor (TIP121 is very easy to find)
- use some other switching device
Of these, I think reducing the LED current or using a larger transistor is probably the most likely solution. Other switching devices (like a relay) are probably more expensive and slower.
To address the sub-parts one by one:
common off-the-shelf LEDs have a capability of blinking with such a high frequency
Pretty much any LED available can be operated at far higher blink frequencies than 1 KHz: White LEDs or others which use a secondary phosphor would be the slowest, often topping off in the 1 to 5 MHz region, while standard off-the-shelf primary LEDs (red, blue, green, IR, UV etc) are typically rated at a cut-off frequency of 10 to 50 MHz (sine wave).
The cut-off frequency is the maximum frequency at which light emission drops to half the initial intensity. Few LED datasheets list the cut-off frequency, but the rise time and fall time of the LED are more common - unfortunately not for the specific datasheet linked in the question.
In practice, one would be safe in topping off at one tenth the cut-off frequency for a well shaped square pulse, so 1 MHz visible light communication is very reasonable. As long as LEDs are SMD or with very short lead lengths, and PCB track / component lead capacitance and inductance are kept to a minimum, driving an LED to 1 MHz is feasible without complex pulse-shaping drive circuits.
More academic info on the subject of LED cut-off frequencies can be found here.
is there a sensor (photoresistor, etc...) that have such a good time resolution for sensing rapidly blinking LEDs.
A CdS photocell would not be suitable for high frequency light sensing: The rise + fall time for common CdS cells are of the order of tens to hundreds of milliseconds. For instance, this randomly picked datasheet mentions 60 mS rise time and 25 mS fall time. Thus the highest frequency it can handle is below 11 Hertz.
Photodiodes and phototransistors are preferred options for sensing higher speed light pulses at low to moderate intensity (i.e. at a distance from the LED source). This datasheet for the BPW34 PIN diode indicates rise and fall times of 100 nanoseconds each, which would tolerate 5 MHz signaling, so keeping a margin of safety, 1 MHz would be comfortable.
For higher signaling speeds and lower signal intensity, super-expensive high speed Silicon Avalanche Photodiodes such as this one have rise and fall times of as little as 0.5 nanoseconds, allowing a 1 GHz signal, well beyond what standard LEDs will support.
If the emitted signal intensity can be high enough, such as by having the LED source and the sensor near each other, or by using suitable lenses, and the desired signal bandwidth is not too ambitious, then a standard LED of suitable color is itself a suitable light sensor. LEDs work well as light detectors, and would be ample for signaling frequencies of hundreds of KHz, perhaps even up to MHz depending on the specific LED chosen for emitter and sensor.
An interesting paper by Disney Research talks about this specific application: "An LED-to-LED Visible Light Communication System with Software-Based Synchronization"
Best Answer
This can be easily done with some logic gates (2 IC's):
I am using NAND's and AND's instead of OR's because the outputs of the LM3914 are active low. I found from another answer that the outputs are open-drain, so I added 100K resistors to all the inputs.
All inputs on the left come from the outputs of the correspondingly named LM3914 outputs.
If all LED's are off, the output of all three gates on the left will be enabled (NAND gate IC1A low, AND gates IC2A and IC2B high), and the output of the NAND gate (IC2A) will be low, keeping the transistor off.
If any LED is on, the output of its corresponding NAND or AND gate will be disabled, and the output of the NAND gate IC1C will be high, turning on the transistor.
There is a special case for LED2-4, which will be blinking. I added a diode D1, two resistors R11 and R12, and a capacitor C1 to form what is essentially a retriggerable one-shot. While any of the inputs to IC1A are cycling on and off, it keeps the input to the IC1C low and its output high, keeping the transistor on. IC1B is being used as an inverter, since the gate was spare.
This shows a simulation of the timer circuit using Circuit Lab. The input to the inverter is kept above the minimum logic high-level of 2v while the input is toggling:
I have not shown the power connections or other pin numbers, but they are available from any datasheet for the parts. You could also use other logic families, such as CD4000.
I realize it really looks like I should be using an OR gate instead of an AND. As mentioned earlier, it is all because the outputs of the LM3914 are active low. It turns out an AND gate is equivalent to an OR gate that has both inverted inputs and output:
Follow the truth table through for each gate if you don't believe me. So the inverted outputs of the LM3914 match up perfectly with the inverted inputs of the "OR", and the inverted output of the "OR" matches up perfectly with the inputs of the next OR.