The turbidity sensor in dishwashers detects if the water is clean or not based on the differences in light intensity that pass through the water. If the turbidity is high, the wash cycle continues. If not, it opens the drain valve.