Ultrasonic Distance Sensor - NoahMacDonald1/387_NM_Final GitHub Wiki

Another feature I've implemented is the use of an ultrasonic distance sensor. When the password is input correctly, and the box opens, the box will wait until you place your hand in front of this sensor to close the box.

Video of what the sensor does in my project.

How does an Ultrasonic Sensor Work?

These sensors are really cool, so if you don't know how they work, here's a quick description.

An ultrasonic distance sensor uses pulses of ultrasonic sound waves to detect where objects are in front of the sensor. Most sensors have 2 "eyes," a sending eye, and a receiving eye. The sensor sends a pulse out of the first eye, and waits for the pulse to bounce off any objects in front of it. If a sound wave reflects back and hits the receiving eye, the sensor knows how far away the object is based off how long the wave took to return. You can even write some code to convert the time values the sensor outputs into distances. This project converts the time values into inches.

Image/Wiring

An ultrasonic distance sensor

The sensor has 2 pins on it, a trigger pin, and an echo pin. The trigger pin tells the sensor to send pulses, and the echo pin returns a signal when a pulse echoes back into the sensor. This means the trigger pin is an output, and the echo is an input on the Arduino.

  • Trigger pin: Analog pin A0 (doesn't need to be analog)
  • Echo pin: Digital pin 10