I chose to experiment with the ultrasonic sensor and used LED lights to indicate specific distances and test the sensitivity of the sensor. I used the ultrasonic sensor because we were introduced to it in class and I wanted to learn more about its applications in conjunction with other pieces.
I used the code outline that we got in class, and added a few modifications. The goal was for the red LED to light up when an object is too close (at a certain distance), yellow when it’s between 2 distances, and green when it’s far enough away. I added the corresponding pin numbers for each LED and 3 distances that create the ranges for each light color.
I wrote 3 “if statements” with inequalities for the specific distances that would turn on the correct LED color.

Pictured above is my actual circuit, connected to my computer. One issue I had was that the red LED was much brighter than the other 2. This suggests that that LED is getting most of the voltage or is the first LED in the circuit (I am bad at circuits). I tried changing the resistors on the yellow and green LEDs from 220 to 100 ohms, but nothing changed. The LED was connected to pin 9, so the next thing I did was try changing the pins that each light was connected to. This kind of worked, so instead the orange LED was brighter than the other 2… this is one issue that I couldn’t fully resolve within the time given for the assignment.
The coding system was pretty similar to languages I’ve used such as MATLAB, which was cool to find out from playing with the circuit. This might be a simple discovery but I also learned that LEDs only have a HIGH and LOW function and you can’t adjust the brightness that way in the code. It was helpful to create variables to define the distances because I could change them later without having to go through the code and change each part. To simplify the measurements displayed, I deleted the inches measurement. The smallest distance (distance1) was 7 cm, the middle one was 14 cm, and the largest threshold was 21 cm, as seen on the right.

I think the LED light system is a good way to show the sensitivity of the ultrasonic sensor, because you can see in real time when the sensor detects changes in distance by the lights changing. I used Lecture 11 from our BME66 class as a reference for building the circuit and creating the code.
Potential uses for the microcontroller in my life could be in DIY robotics projects, or to make safety detection devices such as security alarms or smoke detection alarms. One specific example is the temperature/humidity sensor could be used to create a home temperature system. Microcontrollers have a wide range of practical applications that can be tailored to fit creative projects, or safety systems that are fully customizable and effective.