PROJECT 1: Piano Path (Using Ultrasonic Sensors)

Hello! So you're frantically searching for a project and you don't know if you could successfully finish it, we've been there too. We made the project below in our BTech. 1st Year  1st Semester, hence , YOU CAN DO IT TOO!!

Imagine taking a stroll down the lane, and you hear pleasant piano notes with each stride. It would totally create a mood lifting environment. In this project, we are going to make a mini model of something like this - 


    { Piano Path using Ultrasonic Sensors }

REQUIREMENTS:

1. Arduino UNO (Raspberry Pi can also be used)

2. Arduino Cable.

3. Ultrasonic sensors (x6)

 4. Breadboard (x2)

5.Laptop/PC.

6. Jumper Wires (approx 40 male-male and 5-male female)

 { male-male jumper wires }

{ male-female jumper wires }

7. Speaker (We used Bluetooth speakers)

8. Props (if necessary)

**  Note: We used 6 sensors and the code that is provided is for 6 sensors but you can use as per your need. **

INSTALLATIONS:


CODES:


The Arduino code is basically what we feed to the Arduino through the system. It will contain instructions regarding the connection of sensors to the Arduino using jumper wires. There is a separate Arduino code for testing 1 sensor and then the final code for execution of all 6 sensors. 

The Processing Software is used for setting the audio tones to the respective sensors. Include the 'minim' library in the processor code

(refer to the image below). 


We have provided a set of tones, you can change them if you want. 
      

We are now done with the necessary system set up. Let us move to the hardware part.

ONE SENSOR SETUP:

The ultrasonic sensor has four pins- VCC, Trigger(Trig), Echo, Ground(GND). Now, refer to the circuit diagram below. 


As you can see, we have connected the pin 9 of the arduino to the echo of the sensor and the pin 12 of the arduino to the trigger of the sensor. Connect the grounds and VCCs(5V) too. (Use 4 male-female jumper wires). Connect the arduino to the laptop using the cable. 

Now, navigate to code file 1 sensor --> Arduino1 --> code 1 sensor --> code 1 sensor.ino
 

Make sure your Arduino board is selected in the Select Board dropdown. 

Then click on verify. Also make sure that the Serial.begin() number is the same as the one selected in your serial monitor. You should now observe fast running digits on display in the serial monitor. This is the distance of obstacle from the sensor. As you bring the obstacle closer to the sensor, the value of the digits must accordingly decrease.

Once this is verified, click on upload. Your Arduino code is now uploaded to the Arduino UNO. CLOSE the Arduino IDE tab.

Next, navigate to code file 1 sensor --> Processing1 --> Play_sound --> Play_sound (processing file)
          

You will see that both the play_sound file and the play_sound h (header file) have been opened in the console. You can edit the range of the sensor in the play_sound h file, as attached below.


Now, click on the run button and try placing obstacles in front of the sensor. A tone should be let out from your speaker everytime you do this. If it doesn't work, try unplugging the Arduino cable once and reconnect it. Don't worry, your Arduino code is still stored in the Arduino UNO.
          

  { final one sensor testing }                                                               


SIX SENSORS SETUP:

We will now use breadboards to make our connections. The rest of the process is pretty much the same as one sensor setup. The below circuit diagram however is very important. Make the connections carefully and try it out !!


{ 6 Sensors Circuit Diagram }                                                                                


     {  Detailed View  }                                                                                                    

Notice that we have also made connections between each adjacent sensor and the two breadboards. Make the connections with great caution as they could get really confusing. When you verify the Arduino code, the data in the serial monitor must run without lag. Else there is a problem with your connections.

   {  final result  }    

                                                               

WORKING:

The Ultrasonic Sensor has Trig Pin which acts as the Input of the sensor and Echo Pin acts as the Output.

Ultrasonic sensors emit short, high-frequency sound waves at regular intervals. These waves propagate in the air at the velocity of sound. The Echo Pin emits the sound waves and if there's an obstacle then the sound wave gets reflected back. The Reflected wave is then received by the Trig Pin and the time taken for this process is recorded. All of these operations are carried at a very short span of time. Then the Distance is calculated using the formula -

                           Distance=Speed*Time

by substituting the speed of sound (343 m/s) and the time we get the distance and hence we hear the respective music notes of each sensor.

This article was inspired by - reference article.

Thank you!

 

Comments

Post a Comment