int Opferstecker = 10; //declares pin 10 as sacrificial connector, which should be permanently HIGH/1
int EingangSensorplatz = 4; //Declares pin 4 as input sensor, which switches on LED connection and sets it to HIGH/1.
int LEDVerbindung1 = 7; //declares pin 7 as LEDConnection1
void setup() {
// put your setup code here, to run once:
pinMode(Opferstecker, OUTPUT); //Sacrificial connector set as OUTPUT
pinMode(LEDVerbindung1, OUTPUT); //LEDConnection1 set as OUTPUT
pinMode(EingangSensorplatz, INPUT); //sensor set as INPUT
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(Opferstecker, 1); //sets sacrificial connector to HIGH
digitalRead(EingangSensorplatz); //Reads out input sensor
if (EingangSensorplatz == 1){ //if input sensor position is HIGH
digitalWrite(LEDVerbindung1, 1); //LEDConnection1 on HIGH
}
}
This is my program, theoretically everything should work like this. But the LED is not turned on when the sacrificial plug is connected to the sensor.
In this case simulated by a simple line with HIGH signal.
void loop()
{
digitalWrite(Opferstecker, HIGH); //sets sacrificial connector to HIGH
byte status = digitalRead(EingangSensorplatz); //Reads out input sensor
if (status == HIGH)
{ //if input sensor position is HIGH
digitalWrite(LEDVerbindung1, HIGH); //LEDConnection1 on HIGH
}
}
I wonder: why would you want to read an output pin using another pin?
If a pin is set as output in the DDR register, the input part still works, you can just read VIN register (and that’s what digitalRead() does).
Ok I did not know that.
I want to read the output pin, because I want to check with this pin if there is an electrical connection between the output and the input. Similar to a multimeter continuity tester
For a continuity tester, try the Uno's built-in op-amp LED logic probe: leave pin 13/LED_BUILTIN as a default input, and put your jumper between 13 and the other pins to see the LED light or not.