My friend's birthday is coming, so I want to give him a pretty gift from my learning. So I want to make "Happy Birthday To You" music by buzzer and make an additional feature which is leds that will turn on one by one connected with an ultrasonic sensor that will determine the led that will be turned on based on the distance. Then when my friend arrive to the sound source the lamps will open one by one then he will find the gift near to it.
I used the TinkerCad for simulation
breadboard - wires - buzzer - led for real circuit
Circuit View
I connected a jumper wire from the 5 volt pin on the Arduino to the bottom channel of the breadboard
I connected another jumper wire from a ground pin on the Arduino to the upper channel of the breadboard
Buzzer -> pin 3
(On Ultrasonic Sensor)
Echo -> pin 6
Trig -> pin 7
(In Order from Right to Left)
LED1 -> pin 8 LED2 -> pin 9 LED3 -> pin 10 LED4 -> pin 11 LED5 -> pin 12 LED6 -> pin 13
The jumper wires connected to the LEDs should be connected to the lead on the right, while the left lead of the LED should connected to the ground channel via the wires.
Then, I wrote the codes using the coding blocks, I divided my codes into 2 parts, one for turning on the leds, and another one for sound of buzzer (Happy Birthday music). I used if condition for making variety of brightness using the 6 leds.
I made a simulation, and the result was perfect.
I connected the components using the breadboard with the Arduino. Once I've done that, I copied the code to the Arduino IDE , and I've plugged in Arduino to my laptop, run the code and finally finished. When your hand be near to the sensor, the LEDs should progressively light up, and the buzzer will produce Happy Birthday Music.
I found exclamation mark shows that I should connect a 220 ohm resistor to each LED, because the current through the LED is 53.5 mA, while recommended maximum is 20 mA. The usable lifetime of the LED may be reduced.
So, I connected a 220 ohm resistor to each LED to solve this problem after after the advice from the instructor (Menna).
Ultrasonic Sensor
I used the ultrasonic sensor in this week, I will use the same sensor in my final project. I learned how to use it and this will really help me a lot.
Me with my mate Ibrahim made a smart waving hand using Arduino and DC motor that wave his hand like he say hi, when it feels with any movement in front of him.
Smart Waving Hand using Arduino
Program my Arduino board to control one RGB LED so that it lights up with the following colors in order: Red, Blue, Green, Purple, Orange, and White
Program my Arduino board to control one 7-segment display so that it counts down from 9 to 1