Way to read # of complete circuits

Looking for some ideas - I'd like to build a board where my Arduino is able to know how many complete circuits are on the board.

Just imagine that I have 8 simple pairs of resistors and LEDs; except in some cases, I may take some of the LEDs out, leaving a broken loop.

I would like to be able, using as few input Arduino pins as possible (ideally 1) know how many of the circuit loops are complete.

I was thinking maybe it would be possible by hooking up each of the 8 LED loops up in parallel and then having them all join together to a single input pin on the Arduino, and somehow measure the current that gets through? I've never actually read data in to an Arduino; only output.

All pointers/thoughts welcome. Thanks.

If you have not used the Arduino to read data, then you should take a bit of time to go over the tutorials that come with the Arduino.

Learn to read a voltage (using a potentiometer) with the analog inputs, and read a switch or button with the digital inputs.

How about this:

Connect Arduino output pin to a resistor, connect the other side of the resistor to an analog input pin and to an LED anode, connect the LED cathode to Gnd.

When the output is high, the LED will turn on, and the input pin can be read with analogRead(), the value will be ~(Vf/5V)*1024. For a 2.2V red LED, approximately 450. With the LED removed, the reading will be ~1023.

If you want to save on IO pins, the LEDs can be driven from a shift register instead. Send data out with shiftOut() or SPI.transfer(), then use analogRead() the same way.

Uno (328P in DIP) can read 6 inputs. Many Prominis have all 8 analog inputs, A0 to A7.

Thanks!! I think I could use a shift register as you say to test each circuit individually using a single output pin and a single analog input pin.

I was also reading up...maybe I could use a differential amplifier to measure the current pulled across the parallel circuits? Since I know the voltage, the more circuits that are connected, there will be proportionally higher current. And I can read the output of the DA?

This is similar to the problem of testing a multi-wire cable for shorts and breaks I think - with the
added complication of needing enough voltage to make the LEDs conduct, and needing to measure voltage
not just discriminate between on/off. I think you can power all the loops together and sense the voltage
at the cathode end of each (with a 100k pulldown resistor to guarantee seeing 0V for an open loop). Thus
only analog inputs are needed (perhaps with analog multiplexer for a large number of loops).

Trying to measure the overall current is too sensitive to variations in the forward voltages of the LEDs, current
is an exponential function of forward voltage if there's no series resistance (the worst case), but LEDs also
come in different forward voltages for different types/colours anyway.

An op-amp can measure current. A difference amplifier (typically three op-amps) seems unnecessary.

An op-amp can measure current. A difference amplifier (typically three op-amps) seems unnecessary.

The 3-opamp circuit is called an "instrumentation amplifier", used for very good common-mode rejection,
which is necessary if measuring a current-shunt on the high-side where the voltage difference is a minute fraction of the voltages w.r.t. circuit ground.

To measure a current shunt you require a 4-terminal shunt resistor and a differential amplifier circuit
(which can be a single opamp if its a low-side shunt). The shunt resistance can be of the same order as
wiring resistance, so its essential to take the voltage difference. Shunts for high currents can be a few
milliohms and a few tens of mV full scale, so hardware that works with them is designed for this.

The INA part of INA219 stands for INstrumentation Amplifier.