Sensing the position of something can have really interesting applications such as the laser keybords and pianos where were trendy and popular at somepoint.
I decided to take a simpler approach and replicate the idea of such devices in 1 axis only using an ultrasonic sensor, such implementation can be scaled to 2 axes using an addtional sensor and more complex code, however this is a good first step to learning the idea behing it.
Title of Media
List of components used:
RGB LED light
Ultrasonic sensor
Breadboard
Arduino uno
Potentiometer
Buzzer
3 220 Ohm resistors
Software:
Tiknercad
Arduino IDE
First I started creating the circuit on tinkercad, as it was a relatively simple circuit I didn't need to sketch the idea beforehand or anything.
I connected 3 components to the arduino board, an ultrasonic sensor, and two action devices, an RGB LED and a buzzer.
The ultrasonic sensor is connected directly to the arduino, the RGB LEDs however required a resistance to decrease the current flow to prevent it from blowing up.
As for the buzzer, I wanted to control its volume because it took the recommended current it was extremely annoying , I wanted an easy way to control its volume to adapt it to different environment with different ambient noises.
I then created the code using codeblocks in tinkercad, I programmed the LED to shine different hues when an object is within a specific range of distance from the ultrasonic sensor, the colors used are RED, Orange, Yellow, Green, Cyan, Blue and Purple.
As for the buzzer, I wanted it it beep with a specific frequency for each range of distances, so I created a variable within each if condition and that variable will then determine the frequency of the buzz.
I then simulated the circuit on tinkercad to check for any errors and to test it out.
The next step was to get the code generated from tinkercad, and paste it to the arduino ide, I made slight adjustments to the code which could not be done in code blocks and uploaded the code to the arduino board.
(The adjustments I made is that I made the time of the beep a function of the variable y to give different beeping times for each state as shown in the photo)
Building the circuit was simple as all the components were already placed on the simulation so I just created a digital twin of the circuit in realiy.
Time for testinggg
The following picture shows the different visual feedback the device gives for each detected distance.
Testing but in a cooler wayyy
The device made in the end of week session that I did with a peer at the lab was a really good practive on how the ultrasonic sensor works and directly applying to it, although I can't pinpoint a specific piece of information I learned during that activity I can definitely tell that it improved my understanding of the ultrasonic sensor.
the problem that bugged me the most in the assignment was how poorly the RGB LED is callibrated, the green light for example was much brighter than the red leading to unexpecetd hues, not too much, I'm probably just picky, to acheieve colors I like I had to test out different values and combination on the physical arduino board, but I am satisfied with the end result.
This week I learned how to use the arduino board to control my circuit by sensors or tangible inputs by the user, and I chose to focus in the assignment on the ultrasonic sensor for it can measure distances which I needed in my final project.
Also learning to code in arduino is really fun and the flexibility allowed by will inspire me to try out new things in my project.
I can totally say that the coolest thing I did this week was the waving hand exercise done in the end of the week session in the lab.