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.
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.
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:
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.
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.