A washing machine has a couple of electrical parts that tell it when to fill the tub with fresh water and how much to fill it with. These are the timer control and the water level switch. A third device on this team is the water inlet valve, which contains the valves that start and stop the flow of water from the supply hoses.
Failure with any of these parts can have three results of varying unpleasantness: Bad: The washer won't fill up at all. Worse: Water drips into the tub when the washer is off (this can be upgraded to Worst if you're out of town at the time). Worst: The washer overfills the tub and floods onto the floor (and important "house parts" below), potentially with no end in sight.
Please note that the discussion here does not include the most common cause of washing-machine-related flooding: a burst water-supply hose, which is arguably the best way to flood your house from the inside out.
The timer control (or sequencer) is the part that you activate when you turn the big knob to set the desired cycle stage or wash time, then pull out to start the machine. The timer control unit it behind the control panel-the "dashboard" of your washer, where all the control knobs are. Because timer controls rarely fail, consider this your last stop in your diagnostic adventure.
Water Level Switch
Also called the pressure switch, the water level switch acts as a switchboard to direct electrical current between the timer control and the water inlet valve to complete the various cycles. It also senses how full the tub is via an air-filled tube that runs from the switch (in the control area) down to the bottom of the outer tub (the one you don't see, not the one with the holes in it). As the tub fills, water begins filling the air tube, increasing the air pressure inside until it eventually triggers the switch. You need to know this because a switch failure can be due to an electrical problem (time to replace the switch), or it can be that the air tube is kinked, damaged, filled with water or not securely attached to the tub or the switch. If you're so inclined, you can remove the washer's cabinet and check the air tube and/or test the water level switch for continuity; just be sure to unplug the machine first.
Water Inlet Valve
The hot and cold water supply hoses connect directly to the two nipples on the water inlet valve at the back of the washer. Each valve is controlled by its own solenoid switch. You can test these for continuity to see if either switch has gone bad. Barring an electrical failure, the valves can become clogged with debris or deposits so that they don't close completely, resulting in water dripping or otherwise entering the wash tub even when the washer is off. In this case, it may be possible to remove something obstructing the valve, but chances are you'll simply need to replace the whole inlet valve unit.
Preventing Flood Damage
Once you've experienced a flooded washer episode, you might find yourself thinking more and more about flood prevention in the laundry room (it's funny how that happens). There are a few types of systems made for this kind of protection. Sensor systems connect between the water-supply spigots on the wall and the supply hoses running to the washer and have a sensor that you lay out on the floor beneath the machine. If the sensor gets wet, the system shuts off the water supply to the machine. Pan-and-drain systems have a catch pan underneath the machine that captures flooding water and directs it into a plumbing drain much like a shower drain.
Special shutoff valves install on the wall-end of the supply hoses and allow you to turn off the water supply with one easy motion of a lever, which you presumably will do after each wash load. On one hand this is the safest device because it cuts the water supply at the source and doesn't need electrical power to work. On the other hand, it's completely reliant on your memory; if you're likely to forget to shut off the water, the system is essentially worthless.