This is a fun instrument that lets you play simple tunes by waving your hands in the air!!
The quarantine always makes us crave some fun and so we thought of new things to do with the few components we were stuck with at home.
What better than some music!!!
So here we are, with a simple setup for playing tunes with your hands! Have fun!!
The basic idea is to be able to generate different frequencies of sound based on the position of your hand, which is sensed using an ultra-sonic sensor.
Connect your circuit as per the schematic given below. Paste the given code in your Arduino IDE and upload it.
Keep your sensor in an open space such that there are no obstacles in front of it for at least a meter. Place your palm or any other obstacle in front of the sensor to obtain varying frequencies.
In the given code the sounds are emitted at a fixed time interval for a fixed duration. You can play around with this by changing the value of the variables 'tim' and 'space'.
Also, play around with the way the frequency is calculated from the distance. Here it is:
tones =20+distance*5;
To see the distance of the obstacle measured by the sensor you can add the following code to void setup.
Serial.begin(9600); // Serial Communication is starting with 9600 of baudrate speed
Serial.println("Project by theriveroars"); // print some text in Serial Monitor to indicate setup
And the following code in void loop.
Serial.print("Distance to obstacle= ");
Serial.print(distance);
Serial.println(" cm");
Thus you can view the distance in centimetres.
Have fun with this project and include multiple speakers and sensors to create more complex and fun instruments.
Keep learning!!
Comments
Please log in or sign up to comment.