I'm trying to detect the impedance condition between pins on an external unit. The external unit is not powered (at this stage).
There is a connector block that covers the pins for termination purposes and there are three pins (5, 6 and 7).
Typically this test is done with a multimeter, but I am looking to replicate it with an Arduino. The resistance between two pins is measured, and the expected results are shown below:
5 & 6 = open condition (i.e. maximum impedance)
5 & 7 = closed condition (i.e. less than 5 ohm)
6 & 7 = open condition
So if the Arduino measures an open condition between 5 & 6, a green LED comes on. If it measures a closed condition, a red LED comes on etc etc.
I've attempted using the program below (excluding constants):
void setup() {
// initialize the LED pins as an output:
pinMode(led, OUTPUT);
pinMode(ledGreen0, OUTPUT);
pinMode(ledRed0, OUTPUT);
// initialize serial communications:
Serial.begin(9600);
}
void loop()
{
// setting arduino led low
digitalWrite(led,LOW);
// read the value of the A0:
int A0 = analogRead(condition0);
// condition between 5 and 6
if(A0 < 1){
digitalWrite(ledGreen0,HIGH);
digitalWrite(ledRed0,LOW);
} else {
digitalWrite(ledRed0,HIGH);
digitalWrite(ledGreen0,LOW);
}
// print the analog value:
Serial.println(A0);
delay(10); // delay in between reads for stability
Am I on the right lines or have I over-complicated the program? I was also wondering whether there might be a much simpler way of doing this too. Any guidance is appreciated.