AIR PIANO

COMPONENTS REQUIRED:

  • ARDUINO (uno)
  • IR sensors (x8)
  • Bread board
  • Speaker
  • Jumppers
  • Arduino usb

PROCEDURE :

  1. Connect all IR sensors as shown in circuit diagram.
  2. Calibrate the IR sensors as your wish.
  3. Upload the code given below.

Circuit diagram:

//this code is created by FBSSS
// define IR sensor
#define first 2
#define Second 3
#define third 4
#define fourth 5
#define fifth 6
#define sixth 7
#define seventh 8
#define eighth 9
#define speaker 11
void setup() {
  pinMode(first, INPUT);
  pinMode(Second, INPUT);
  pinMode(third, INPUT);
  pinMode(fourth, INPUT);
  pinMode(fifth, INPUT);
  pinMode(sixth, INPUT);
  pinMode(seventh, INPUT);
  pinMode(eighth, INPUT);
  Serial.print(9600);
}
void loop() {
  int value1=digitalRead(first);
  int value2=digitalRead(Second);
  int value3=digitalRead(third);
  int value4=digitalRead(fourth);
  int value5=digitalRead(fifth);
  int value6=digitalRead(sixth);
  int value7=digitalRead(seventh);
  int value8=digitalRead(eighth);
  if(value1==0){tone(speaker, 131);}
  else if(value2==0){tone(speaker, 147);}
  else if(value3==0){tone(speaker, 165);}
  else if(value4==0){tone(speaker, 175);}
  else if(value5==0){tone(speaker, 196);} 
  else if(value6==0){tone(speaker, 220);}
  else if(value7==0){tone(speaker, 247);}
  else if(value8==0){tone(speaker, 262);}   
  else
  noTone(speaker);
}

ENJOY WITH YOUR AIR PIANO

Leave a Reply

Your email address will not be published. Required fields are marked *