Quote:
Originally Posted by andreboos
Why would an unconnected pin report random values? Or do you just mean it would be a noisy zero?
|
Mostly, it would be a "noisy zero" as you put it. But, if the pin is floating, it could have residual charge trapped since the last closure of the switch. In other words, when the switch closes and you read 5V. Then the switch opens and it may take a period of time for the charge to drain internally from the signal pin. It depends on the analog bumper design, the period could be long since you did not provide a drain path. The best case is that it drained relatively quickly and you didn't even notice it. The worst case is a delay before the signal pin reads 0. For a limit switch to stop something, a delay may or may not be acceptable. Certainly comparing it to 2.5V instead of 0 helps a lot because it is certainly reaching 2.5V a lot faster than 0. In general, it will probably work in your case but not a best practice to float a pin.