Continuity test

Is it possible to set one input HIGH and another input LOW, then test if there's a conducting path between those two inputs? I'm trying to test a total of 20 leads for continuity with each other, in both directions (it's an LED display) and output the conducting paths to the serial terminal.

No, but you could set one pin to OUTPUT and HIGH, and another pin to INPUT, and connect something between the two. If it conducts enough it will give a HIGH on the input. You might like to tie the input pin to ground through a large resistor (10K say) to stop it floating with an open circuit component.

Better still, use an analogue input, then you can calculate the resistance of the component as half of a resistive divider.

I don't think that it's a good idea. Continuity test on a multimeter is to test if there is a good conducting path between two points, so it is essentially, a resistance test. If you try to test a live circuit, you may damage your multimeter. I don't know why.

Multimeter Instruction Booklet:
Never perform resistance tests on live circuits.

It might help to clarify that this is going to be connected to a four digit seven segment display, and I want to test whether lead one high and lead two low, and vice versa, conduct, then move on to lead one and lead three, etc.

Majenko gave me an idea, though, to use the INPUT_PULLUP setting on a pin to represent high, and if it gets pulled low then the path is conducting, correct?

Not for LEDs, no.

The forward voltage drop of the LED will be too high for it to register as a logic low.

What you want is all your IO pins tied to ground through 10K resistors. Then you connect the lines to the pins on the LED display.

You then set ONE as an output, and drive it HIGH. All the others should be set to INPUT.

Then, you scan through all the inputs, and if it coincides with an LED the right way round (anode on output, cathode on input), that input will read as HIGH. If it's not, it will read as LOW.

For example - Connect 10K resistors between pins 2 and 3 and ground. Get an LED, and run this sketch:

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  pinMode(2,INPUT);
  pinMode(3,OUTPUT);
  digitalWrite(3,HIGH);
  if(digitalRead(2)==HIGH)
    Serial.println("Conducting 3 to 2");
  
  pinMode(3,INPUT);
  pinMode(2,OUTPUT);
  digitalWrite(2,HIGH);
  if(digitalRead(3)==HIGH)
    Serial.println("Conducting 2 to 3");
    
  delay(1000);
}

When you connect an LED between pins 2 and 3 the serial monitor should tell you which way the current is flowing. The LED won't light up as the input is too high impedance.

Trying that then. I don't know if I have enough resistors though, I've exhausted half my 10Ks and all my 1Ks just hooking up the display to ensure there's always a resistor!

Can I just not use those resistors if I flicker through the possible paths fast enough?

majenko:
Not for LEDs, no. The forward voltage drop of the LED will be too high for it to register as a logic low.

Works fine with the yellow LEDs on my desk. Pin 2 is the "probe". The other side is GND. LED on pin 13 lights with continuity.

void setup( void )
{
  Serial.begin( 115200 );
  pinMode( 2, INPUT_PULLUP );
  pinMode( 13, OUTPUT );
}

void loop( void )
{
  if ( digitalRead( 2 ) )
  {
    digitalWrite( 13, LOW );
  }
  else
  {
    digitalWrite( 13, HIGH );
  }
}

Would those pullup resistors also supply sufficient impedance for the LEDs to light (or at least conduct) without burning out?

xolroc:
Would those pullup resistors also supply sufficient impedance for the LEDs to light

The yellow ones I have do not. The red ones I have do.

Do you need them to light?

(or at least conduct) without burning out?

Burning out? I don't understand.

Confirmed. For half a dozen different LEDs that sketch lit up pin 13 if there was an LED between pin 2 and Gnd, the right way around.

The LED itself lit up pretty dimly, if at all.

Put it like this: Even with the internal pull-ups there is still 5V between pin 2 and Gnd, which is a sufficient condition for the diode function of the LED to conduct in the forward direction. However there was 0.15 mA of current flowing which is not enough, or barely enough, for the LED to light.

That figure sounds about right, with 5V and a 30K pull-up, you would expect 0.16 mA to flow.

Yes, this technique worked fine, and got the results I needed. Thanks for the help!

xolroc:
Can I just not use those resistors if I flicker through the possible paths fast enough?

I wouldn't risk it. You need a current limiting resistor to protect the LED, and I guess there's some chance you could damage the ATmega output if the LED did burn out. Silicon fails in one of two ways when that happens - it either goes open circuit, which is safe, or it melts to a conductive blob, which isn't.

You have a point. The method I ended up using had all connections to +Vcc through pullup resistors though, so that was definitely enough.

Yes, that makes sense.

I'd be wary of arranging hardware so that a bug in the software could kill it though :slight_smile: