You are expecting either 0v or 5v at pin 9...
Do you have a common Ground between the Arduino and the 5v input?
When there is no 5v input, is the input pin pulled to Ground? ... if not it can float... ie. be undefined.
You are expecting either 0v or 5v at pin 9...
Do you have a common Ground between the Arduino and the 5v input?
When there is no 5v input, is the input pin pulled to Ground? ... if not it can float... ie. be undefined.