Ultrasonic Rangefinder using a Chinese knock off of an Arduino Nano copy by classdisk

This sketch reads a HC-SR04 ultrasonic rangefinder and returns the distance to the closest object in range.
This sketch shows a working example of saving variables to the eeprom using eeprom.get and eeprom.put. There is an alarm that sounds a buzzer when an object is within a re-set-able distance (in inches) from an object, and also 3 leds that turn on in succession 3 inches apart prior to sounding the alarm to indicate the set distance to the object has been reached. Two push buttons are used to increment and decrement the alarm distance. Another push button is set up to turn the alarm on and off. An LCD is used to view the distance in inches and centimeters when an object is placed in front of the sensor and also prints to the LCD if the alarm is set to on or off.

Embed This Sketch

Use the following HTML code to embed the sketch code above in your blog or website.

<iframe style="height: 510px; width: 100%; margin: 10px 0 10px;" allowTransparency="true" src="https://codebender.cc/embed/sketch:445653" frameborder="0"></iframe>

Embed The Serial Monitor

You can also embed the Serial Monitor section! Just use this HTML code.

<iframe style="height: 510px; width: 100%; margin: 10px 0 10px;" allowTransparency="true" src="https://codebender.cc/embed/serialmonitor" frameborder="0"></iframe>