Guest Post by Toni Norrell | Back-Up Sensor using the Ultrasonic Ranger

Another fantastic post from Toni Norrell (@ToniNorrell).

A friend of mine I’ll call Sandy drives a very fancy car! Her car has all the bells and whistles you might say. It has cameras/sensors all the way around that beep a lot. She has a tendency to ignore them when pulling in and out of parking spots because they beep when she is too close to the curb, they beep at the cars parked on either side, they beep if a car drives behind the car, etc. This particular day she ignored the beeps and backed right into a parked car! Like any good friend would, I made her a pillow that says “Respect the Beep.”

Michelle & I started thinking about how this incident could be modeled using the Ultrasonic Ranger & Innovator Hub. We wanted to write a program that was similar to a back-up sensor on a car. This expands upon my previous post about first collecting distance data from the ultrasonic ranger.

  

The program connects the ranger and uses the warm-up program that Michelle talked about in a previous post. The distance variable is initialized and a while loop is setup to read, get, and display the distance as long as it is more than .01 meters.

The If Then looks at distances between 0.1 and 0.5 and sets the hub to send a sound with a particular frequency if the ranger is within that distance.

When the “car” gets closer than 0.1, a higher frequency sound is heard.

We set both of these sounds inside For loops to provide more of the “pulse-like beeping” you often hear from a car’s back-up sensor.

Here is a copy of the complete TNS file for you to try! Also, here’s a short video clip of this program in action:

What other ways could this program have been written?
How could it run even more like a back-up sensor on a car?

Toni Signature

2 thoughts on “Guest Post by Toni Norrell | Back-Up Sensor using the Ultrasonic Ranger

Share your thinking...!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s