Starpuzzle: Detect current in seperate circuit with leds

Hey,

I would like to build a star puzzle with many leds (45 LEDs). The LEDs can be switched on and off using switches. To solve the puzzle, certain LEDs should be switched on to form a star image. As soon as an LED that is not part of the solution lights up, the puzzle is not solved. I run the LEDs that are relevant for the solution (10 LEDs) directly via the arduino. The other 34 leds are only intended as a distraction. I operate them in a parallel circuit with their own 5 V power supply.

How can I use the arduino to check whether one or more leds are switched on in this seperat parallel circuit?

I have already tried it with a current sensor that I have connected to the arduino. But the current flow via an LED seems to be too low.

It doesn't matter how many leds are switched on in the parallel circuit. As soon as at least one is lit, this should be detected by the arduino.

Can you help me how I can implement this?

Thank you very much

So the Arduino is not controlling those LEDs?

Yes, correct the LEDs are not controlled by the arduino.

You have current limiting resistors for each LED? Right? Put the resistor between the LED and ground. The LED does not care where the current limit is placed.
The Arduino digital pin can connect to the junction of the LED pin and the resistor. IF the LED is off, there will be zero volts at the junction. If the LED is on there will be a + voltage at the junction. Your code can test for high/low for that LED.

A simple drawing for better explanation:

I need to know if any of the parallel leds is switched on or if all switches are open, so no led is on.

And test status of X pin, Y pin and Z pin.

Thanks but is there also a way to not use one pin for each led?
Because there are 30 leds and I don't have that many free pins left on the arduino. I don't need to know which led is switched on, I only need to check if one or more leds of the shown circuit are switched on (or all are switched of). Could i do it this way:

In this case all LEDs current pass through arduino X pin and this pin no suport more them max 40 Ma.

Maybe something along the lines of this if you could get the Rs right.

Oops... I forgot the LEDs... corrected...

         /         +-----+   +------+
 +------/ -----+---| LED |---| R220 |--+
 |             |   +-----+   +------+  |
 |       /     |   +-----+   +------+  |
 |------/ ---+-|---| LED |---| R220 |--+
 |           | |   +-----+   +------+  |
 |       /   | |   +-----+   +------+  |
 +------/ -+-|-|---| LED |---| R220 |--+
 |         | | |   +-----+   +------+  |
 |   ______|_|_|_                      |
 |  |            | +---------+         |
 |  |  74HC165   | | Arduino |         |
 |  |____________| |         |         |
 |            |Q7  |         |         |
 |            +----| DIO     |         |
 |                 +---------+         |
 |           +------+                  |
 +-----------| P.S. |------------------+
         +5V +------+ GND


All manner of options.

Could I use an optocoupler like the pc817?

Draw the circuit

If at least one led is switched on, then the optocoupler should be active and pin x on arduino gets high.

Thanks, i dont have so much experience, could you explain 74HC165? And can it handle up to 30 leds?

The 165 is a 8-parallel to 1-serial shift register. Great for bunches of pushbuttons on one Arduino pin. You would need 30 / 8 = 4 shift registers.

Post #12 with a 30-input NAND (or OR) gate would work.

Sorry, I misread your question. My solution is for detecting if one or more switch is open. Similar logic would work for your question.
The problem with your optocoupler circuit is that the current through the opto is 30 times greater when all the switches are closed.

The current through the opto LED PC817 is max 50 mA.

Ok, i see the problem. Thanks, for the explanation. Maybe i will use an arduino mega, then i will have enough pins for all leds.

Do I need diodes if i use the shift register? Like shown in post #7 or # 10

If i will use an arduino mega, could i do it like this? If i need the diodes, can someone give a short explanations why they are important?

Or could i use an INA219 Sensor? It seems that this sensor can measure lower currents than the ACS712 which I tried before (and didn't get any useful outputs, becaus the current is to low).

That would be much easier to implement than the shift registers.