Here's the situation:
int trigger = 12;
(...etc)
if(digitalRead(trigger)==HIGH){
digitalWrite(8, HIGH);
}
if(digitalRead(trigger) == LOW){
digitalWrite(8, LOW);
}
I have pin_8 connected to voltage supplier with a wire.
when I plug the wire, it normally goes to HIGH
meaning that it read HIGH correctly
but when I unplug the wire, it keeps HIGH, why?
I know that when an INPUT is not connected to circuit, it reports random changes in pin state
but how can I put the pin state at LOW when it senses no current, and after it been previously set to HIGH?