I'm making a bomb prop with an external trigger connection
The connection will get a constant 5V power supply so if it's disconnected, the external circuit knows that, and detonates the smoke bomb or what ever
But I also want that the bomb will "explode"
So the Arduino will have the external trigger connected on a digital pin configured to output
An I want it to connect SOMEHOW to an input pin so I'll know when it's disconnected
This seems to work nicely but the wire pin gives just a little bit of current
I'm using a 2N4401 transistor for the external device and its needs more current
#define epin 4
void setup(){
pinMode(epin, OUTPUT);
digitalWrite(epin, HIGH);
}
void loop(){
// If the LED on pin 13 is on, it meens that the connection was broken
digitalWrite(13, digitalRead(epin));
delay(15);
}
What did you want? To treat the pin as an OUTPUT and INPUT? That you can't do simultaneously.
omni96:
It will return low if connected to the external circuit
And high when disconnected
It can't do that. digitalRead() only reads the PORT register. The PORT register, when configured as an output, has no idea what voltages are being applied to the pin.