Concept
Expanding upon the unusual guitar switch I made for last week’s assignment, I decided to introduce a new feature that will detect the distance between the guitar and the edge of the table. I got the idea for this feature from my own carelessness, as I often knock my guitar into my desk on accident. Using input from the ultrasonic sensor in our arduino kit, a red LED light will light up as a warning whenever the body of the guitar gets too close to the edge of the desk.
Setup and Code
Like my previous assignment, I covered my guitar pick with aluminum foil to make it conductive and then taped it to a wire; another wire was attached to a larger sheet of aluminum foil and then the sheet was taped to the bridge of the guitar, allowing the yellow LED to light up when the pick makes contact with any of the guitar strings. On the other half of the breadboard, I installed the red LED bulb and the ultrasonic sensor on the edge facing outward so that it can be positioned on the edge of the desk.
I learned how to make the LED light turn on and off according to ultrasonic sensor input from these posts on the Arduino Forum:
- https://forum.arduino.cc/t/ultrasonic-sensor-with-led-how-can-i-do-this/920861
- https://forum.arduino.cc/t/hc-sr04-always-returns-zero/206641
While trying to get the red LED to work properly, I struggled for a good amount of time as the ultrasonic sensor kept retrieving 0 and only 0 as values on the serial monitor. I eventually realized that I, being my careless self, put the wrong number for the sensor’s echo pin in the definition at the start of the code.
Demo
Reflection
The biggest challenge for this assignment was learning how to use the ultrasonic sensor, since we did not get to practice with it in class, but thankfully there were a lot of tutorials on the internet. And while it wasn’t particularly complicated, I’m proud of managing to get it working (despite the minor hiccup with the code as a result of my carelessness).