USING WATER AS A TILT SWITCH

Peter_I:
And notice, that as soon as you use iron needles in sodium chloride solution, and add a bit of electricity.... your positive needle is going to dissolve surprisingly fast.

You can make the problem smaller by supplying the electricity from an output pin, and only write it HIGH when you want to perform the reading of your tilt sensor.

Actually, it is even easier than that. You enable the internal pullup (by writing HIGH to the same pin whilst it is defined as an input) just long enough (should be immediate, but give it a few microseconds) to make the measurement and then disable it by writing LOW to the pin.

The internal pullup is estimated as about 10k, and the resistance in salted water should easily be less than 1k. The reason for the much larger pullup is to ensure that the resistance of the water pulls the input voltage well below the high/ low threshold for sensing.