Monthly Archives: June 2016

Ultrasonic Toggle Switch Source Code (Arduino)

// ultrasonic toggle switch // Joe Schembrie aka ‘Engineer Zero’ // comments 6-23-2016 // the circuit for this sketch consists of a yellow and green LED and an ultrasonic distance sensor (pinger). // when a hand approaches the pinger, the yellow light comes on with the approach. // when the hand gets close enough, the value of green is toggled.   // IE, if the green LED was off, it turns on.  If it was on, it turns off. // to see this in action, visit https://engineerzero.wordpress.com/2014/06/01/ultrasonic-toggle-switch/ // The green LED toggles only once while the hand is near.  // IMPORTANT // The hand must be retracted far enough so that the yellow light goes off // for the green LED to be toggled again.  This prevents ‘bouncing.’   // NOTE:  In some respects, this device seems to work best when the yellow light is disconnected. // NOTE ON NOTE:  I wrote the above note a couple years ago AND DON’T REMEMBER WHY. // Now for inclusion of the library.   // the NewPing.h library is available on the Internet. // I did not write it.  I cannot answer questions about it. // It comes with documentation on the Internet.   // Google away! #include <NewPing.h> #define TRIGGER_PIN  11  // Arduino pin tied to trigger pin on the ultrasonic sensor. #define ECHO_PIN     10  // Arduino pin tied to echo pin on the … Continue reading

Posted in Uncategorized | 1 Comment