Distance Visualizer

I made this little "distance visualizer" in December of 2017. Basically, an ultrasonic rangefinder tells the computer how far away an object is through the serial port. Instead of looking at the numerical data in the serial window, the data is taken by another program called "Processing."

In Processing, the data is turned into a moving, real-time bar graph that shows the distance from the object. There are also ways to control the Arduino from Processing (communicating through the serial port), but for this project we only collect the rangefinder data to better visualize it.

One of the interesting quirks of this project is with the rangefinder. I had to eliminate extreme noise (>3000 cm), but not eliminate the max measurable distance (around 250 cm). The processing code averages the two last distances if it measures a large difference between them. This eliminates quick spikes on the screen if a large distance creeps up.

Below, there are two files. The .INO file for the Arduino IDE and the .PDE file for the Processing IDE (configured to Java). This was originally built for an Arduino Uno using an Elegoo HC-SR04 Ultrasonic Rangefinder.

Best of Luck!

CONNECTIONS

On the Arduino:

Set trigger pin to 10 on the Arduino

Set echo to pin 11

Connect to Ground and VCC

Here is what the screen should look like in processing, with a sliding grey bar showing distance from the object:

(Code Included Below)

Arduino and Processing Code