Pcom: Week 4 – Distance Detection Tool and Maybe More…

Basic Distance Detection Tool

Learning about analog output and the mechanism of Pulse Width Modulation made me understand many common life phenomena from a more fundamental perspective. One common application of analog output I thought of right after getting familiar with the class material is the backup radar for vehicles – the alarm will go off and the pitch would get higher if the back of your car is getting closer to an object. So I decide to to combine ultrasonic sensor and speakers and make a simple distance detection tool.

This simple application uses ultrasonic sensor as an analog input, reading the serial value of distance, and having the buzzer to generate a frequency/pitch that positively correlates to the distance.

 

Distance Detecting Tool with Tone Change 

Then I decided to combine the tone function with ultrasonic sensor. So I divided the distance print value into two categories: distance farther than 50cm as “out of range” and distance less than 50cm as the “keyboard range”. And within the 0cm to 50cm range, I made 10 categories, each covering a range of 5cm, and gave them keys varying from C4 to E5.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to Top