This week, my idea is to build a modern, sensor-activated music box or a kind of interactive radio. The device will be designed to respond to user interaction in two different ways.
First, it will have a push-button that, when pressed, triggers a specific musical note and an accompanying color on an RGB LED. Second, it will use a motion sensor to detect movement, which will then trigger a completely different musical note and a new color combination. It's essentially an interactive sound and light device that plays different outputs depending on whether it's triggered by touch or by motion.
My inspiration for this project comes from classic, dedicated music players like the iPod. I got interested in the idea of creating a simple device that could play different musical tones or melodies.
What really excites me about this project, and why I care about it, is the possibility of combining sound with light. I think it's a cool concept to have each musical note trigger not just a sound from the buzzer, but also a unique, matching color from an RGB LED. It's about exploring how to create a richer, more interactive experience by pairing audio and visuals, all inspired by the simple function of classic music gadgets.
The theme chosen
I've chosen the them that is "to built a Smart Device for Your Backpack" & the device makes work more fun
Softwares
I used Google to search for ideas and to get visual information that helped me get inspiration and develop the concept.
I used Tinker cad to model and simulate my circuit and to test it before circuit building
For coding and code uploading I used Arduino IDE
Tools & Components
Wiring & Design
I sarted my circuit by listing the components that I needed as :-
INPUT & Sensing Components :
UltraSonic Sensor
Slide Switch to perform manual mode
OUTPUT Components :
Buzzer to output tones
LEDs to output light refering to working mode
Final Circuit Simulation
Simulated circuit that works on switch and ultra sonic sensor
After I'm done with the wiring i moved to the coding phase with the results I got from search about Ultrasonic Sensor Coding
The Code plan is :
to first depend on a switch ,
if this switch is connected so The Buzzer Works with the first tone and red LED is lit up
if the switch is not connected the it heads to the sensor of ultra sonic to work in the condition of the sensor , we previously set the sensor that it gives response when the reading is in a range of 40 cm So when there is a body in the range of 40 cm buzzer works with a tune that's different from the first tune in the duration and power and a green LED is lit up
And if a body or something is in a range of more than 40 cm nothing happens no LED is lit up and no buzzer works .
Starting of coding phase
First I start with defining the the variables I'm going to use as pins numbers
I add two other variables that I'll need in Ultra sonic sensor calculations
With the setup section in the code I do the set up for thee pins i gave them variables earlier and set them as output pins & input pins
For the switch I make the input type input_pullup to use values High/Low reversed for the switch when it's in the circuit because the inner resistance in the Arduino that it will use when we use pullup
I set the speed that the encoder will use in encoding with serial.begin
I now head to the Infinity loop section where I put the commands that are going to be repeated all the time
I now head to
I set the ultra sonic equations that will calculate the distance between the sensor and the object using the 2 variables that I set earlier.
and also we set a delay for the code repeat
When the If case doesn't take place we head to the other condition where the ELSE IF condition code is & we make the code for ultra sonic when the body is in range of 40 Cm A Buzzer plays a specific tone and a green LED is lit up so we set the code that is responsible for that
We set the code for the case that the project is off when the switch is off for the manual mode and ultra sonic is out of range so automatic mode is off , and the code is for the Buzzer to be off so are the LEDs
We set a short time delay at the end of the code for the repeat process to be smoother.
Wiring and circuit building phase
We make the circuit and the wiring with initially way
From the beginning :
First I connect my components to the circuit
I start with connections
I connect resistances with the LEDs to protect them from over current
After I get the LEDs connected and the wires connected I put the main wires to be ready to get connected to the Arduino
Now I connect the ultrasonic sensor
I also connect the buzzer and connect the switch I'm gonna use
Now when my initial circuit is complete I upload the code using the Arduino and Arduino IDE software
Then I tried the code with my initial circuit with the breadboard and wires without an enclosure right now
When the result is good and everything is complete I make the extensions to my wires and components so that they be able to be set and installed in the cardboard enclosure
Then I produce the final project product and it's out to reality
Final Output Project
A circuit that contains Ultra sonic sensor and a buzzer for 2 modes and 2 different LEDs that are turned on with the buzzer tone in deferent modes manual & automatic
Not my peers but yeah I already searched and looked for the pin out and the coding way of the Ultra sonic sensor
One of the first problems I faced was with the ultrasonic sensor because I wasn't sure how to write the code to get the distance from it.
The solution was to search online for the right way to code it. I kept looking until I found some good examples, and then I understood how to get it working correctly.
The second challenge was with the buzzer. I tried to make it play a song, something I had done before in a different project. But when I tried to add the song code to this project, I ran into problems because the code became too complicated with the other parts, like the sensor and the switch.
The solution was to give up on the idea of a full song. Instead, I decided to just use simple tones with different sounds and durations. This made the code much simpler and fixed the issue, so the buzzer just makes a basic beeping sound now.
I can now use Arduino IDE to code my final project with various sensors and various components
I can use if cases code to switch between modes in project
I can use push button & slide switch to make different modes for the same objects
That every component could have a code to program it like buzzer we could program it