theriveroars
Published © GPL3+

Simple Hand controlled instrument

A DIY instrument that you can play by moving your hands in the air!!

BeginnerFull instructions provided5,020
Simple Hand controlled instrument

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Speaker, Mini
Speaker, Mini
Any speaker will do
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Here is the fritzing file

Make these connection, upload the code and you are ready to go!

Pictorial representation

Follow these connections carefully

Schematic representation

Code

Code for tunes with hand gesture

Arduino
Paste this code in your Arduino IDE.. Try tweaking the values as mentioned above and have fun!
#define echoPin 6 
#define trigPin 5 
long duration; // variable for the duration of sound wave travel
int distance; // variable for the distance measurement
int tones;  
int tim=200;// duration for which one sound pulse will last
int buzzerPin = 8;
int space =500;

void setup() {
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
  pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
  pinMode(buzzerPin, OUTPUT);
  }
  
void loop() {
  
  //Finding distance of obstacle using ultrasonic sensor
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  
  duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds
  distance = duration * 0.034 / 2; // Distance = time*speed/2
  
  //Emitting sound as per the distance
  
  tones =20+distance*5; //calculating the frequency that has to be emitted

   tone(buzzerPin, tones, tim); //emits sound at the specified frequency and for the specified duration
    
   delay (space); //delay between each beat
  
}

Credits

theriveroars
2 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.