cleaned up 'water' program code

The command line program 'water' for controlling
the valves has been cleaned up.

  - better error messages
  - grouped together related code
  - eliminated use of a global variable
  - added more error checking