My Idea is to create a distance warning for people with hearing difficulties by warning them with light instead of alarm sound using ultrasonic sensor .
I needed to use TINKERCAD to simulate my electronical circuit and I also used the website to create my code . It was a technical requirement to use code blocks in TINKERCAD for this week and that's that I did .
I also used Arduino IDE to upload my code to my Arduino .
I needed to use Arduino Uno ( brain)
Breadboard
Ultrasonic sensor ( input )
RGB LED ( output )
I started with searching for the right way to wire ultrasonic sensor to Arduino . ( You should wire the trigger to a signal output and the Echo to an Analog output )
Then I added The RGB LED to the circuit , wired the cathode to the ground and only wired the red an green RGBs' pins .
I used code blocks to create my code and started to simulate . I was surprised that the RGB LED turned the yellow color light instead of red or green. So, I added another output to my condition that when the distance is more then 50 cm then the green light is turned on and red light is off . Else , The Red light will be turned on and the green on is turned off . That was the trick that helped me to avoid color mixing in RGB LED .
I wanted to add some reality to my circuit so I add blinking to when the distance is less than 50 cm as a warning of danger .
I had a problem showing the right light colors depending on the condition I created .
I solved this problem by adding an output that makes the right color turned to HIGH and the other color turned to LOW .
I was so excited for this week . I wanted to learn more about electronics and coding and I don't regret it at all .
Can't explain how happy I became when the components really worked without issues .
Here are the steps of bringing my circuit to life .
Trust the process ...
I created the same wiring showed in TINKERCAD .
I wired the 5 V Arduino output to the positive row of the breadboard
The ground of Arduino to the negative row of the breadboard .
Ultrasonic sensor :
I wired the VCC to the positive row of the breadboard and the GND to the negative one .
wired Trigger to the digital pin 4
wired Echo to the analog pin 3
RGB LED :
I wired the common to the negative row
the red pin to the resistor then to pin 6
the green pin to 330 ohm resistor then to pin 5