I have a water tank and I have three of these float switches mounted at various depths:
When the float is raised in the horizontal position, the circuit is complete and current can pass through. When the float is in the vertical position, the circuit is totally disconnected.
From reading around:
"If the pin is totally disconnected, it will randomly read HIGH and LOW."
So if the float switch is totally disconnected (float is in the vertical position) and connected to a digital pin that doesn't have an internal pullup resistor, the pin will still just randomly read HIGH or LOW due to environmental electromagnetic interference? Is that it? Basically, if the pin's not connected, it will still have random continually-changing voltages running through it, and some of those voltages will hit levels that cross the threshold for "HIGH" while some of them won't at different times.
Hmmmm... how would having random voltages ever be useful? Why don't all the pins have built-in pullup resistors to "quiet down" the voltage when there is no signal present? It seems like the internal pullup resistor can be enabled or disabled on command anyway since you have the explicitly set INPUT_PULLUP in pinMode for that pin.