This is an idea for using an ultrasonic distance sensor (aka ‘pinger’) as a toggle switch. I’ll show it first and then explain:
As the hand approaches, the yellow light comes on to indicate that the switch is in aware mode.
When the hand is close enough, the green light toggles. That is, if it’s off, it goes on. If it’s on, it goes off. The yellow light, having done its duty, goes off.
The yellow light remains off while the hand is retracted to indicate that the aware mode doesn’t activate again until the hand is fully retracted. This is to prevent the ultrasonic equivalent of what is called ‘bounce’ in mechanical switches.
So what are the applications of such a switch? Suppose you have a runaway robot and you’re shouting at it but the background noise is high and so you take out your remote but there’s radio/IR interference too. You could chase after it and slam a mechanical switch on the back, but maybe that is getting too close for safety.
So here’s another solution: simply reach out toward the robot, and when you’re close enough (but still at a safe distance), the pinger detects your hand and deactivates the robot.
A more mundane application would be to turn fans and lights on and off more conveniently.
(In case you’re wondering, I had oatmeal for breakfast.)
Buy at Amazon:
Vivotech Hc-sr04 Arduino Ultrasonic Distance Measuring Sensor Module Good Compatible
Hi I really love your toggle switch because I wanted to make one but couldn’t code it to do so. I am currently making a cube timer using the ultrasonic sensor. Could you share the code to use the sensor as a toggle switch. Thank you
I’ve had some trouble with formatting in WordPress, but I think they’re solved now. See my blogpost https://engineerzero.wordpress.com/2016/06/23/ultrasonic-toggle-switch-source-code-arduino/