Infrared sensor: work by sending out beams of invisible infrared light. A Photo Detector on the switch detects any reflection of this light to determine if there is object nearby.
Ultrasonic(acoustic)sensor: use a transducer to transmit inaudible sound waves at various frequencies in a preset sequence. Then measure the length of time the sound takes to hit a nearby object and return to a second transducer on the switch. It measure the time it takes for sound pulses to "echo" and use this measurement to calculate distance.
Capacitive sensor: It senses distance to objects by detecting changes in capacitance around it.
A radio-frequency oscillator is connected to a metal plate. When the plate nears an object, the radio frequency changes, and the frequency detector sends a signal telling the switch to open or close. Disadvantages : sensitive to objects that conduct electricity. Used to detect metal & non-metallic objects(wood, paper, liquid) . Range is small.Detects milk in cartoons.
Inductive sensor: sense distance to objects by generating magnetic fields. Similar to metal detectors. A coil of wire is charged with electrical current, and an electronic circuit measures this current. If a metallic part gets close enough to the coil, the current will increase and the switch will open or close accordingly. Disadvantage:only detect metallic objects. Detects metallic caps- range is small