Billysugger:
The above methods will slow the electrolytic errosion of the electrodes, but will not prevent it. To prevent it completely, without plating with expensive metals lilke gold, use a biphasic measurement as follows
Easier: Put a polystyrene capacitor - a fraction of a microfarad - in series with the sensor wire (using the internal pullup I cited earlier). While the pin is set LOW between measurements, switch it to an output, and back to an input before enabling the internal pullup for the next measurement.
Peter_I:
I guess the purpose of this is "build your own".
Commercial "ball in a metal tube" tilt switches cost very little.
I do not think any of use ever doubted that this thing was purely as an amusing exercise, with no "real world" application whatsoever. Clearly proper tilt switches are dirt cheap, even triple axis accelerometers.