on
Wearable Arduino Tone Generator by Brian VonKaenel
[Arduino CDEFG Note Coding]
int piezoPin = 10 ;
/* declare the pin which the piezo speaker is attached to */
int keyOne = 2;
/* declare the first soft button */
int keyTwo = 3;
/* declare the second soft button */
int keyThree = 4;
/* declare the third soft button */
int keyFour = 5;
/* declare the fourth soft button */
int keyFive = 6;
/* declare the fifth soft button */
void setup(){
  pinMode(piezoPin,OUTPUT);
  /* declare the piezopin as output */
  pinMode(keyOne,INPUT);
  /* declare the first soft button as input */
  pinMode(keyTwo,INPUT);
  /* declare the second soft button as input */
  pinMode(keyThree,INPUT);
  /* declare the third soft button as input */
  pinMode(keyFour,INPUT);
  /* declare the fourth soft button as input */
  pinMode(keyFive,INPUT);
  /* declare the fifth soft button as input */
  digitalWrite(keyOne,HIGH);
  /* send 5V to the first soft button */
  digitalWrite(keyTwo,HIGH);
  /* send 5V to the second soft button */
  digitalWrite(keyThree,HIGH);
  /* send 5V to the third soft button */
  digitalWrite(keyFour,HIGH);
  /* send 5V to the fourth soft button */
digitalWrite(keyFive,HIGH);
  /* send 5V to the fifth soft button */
}
void loop(){
  if(digitalRead(keyOne) == LOW){
  /* tests if the first soft button is pushed */
   digitalWrite(piezoPin,HIGH);
   /* sends 5V to the piezo speaker */
   delayMicroseconds(1911);
   /* waits for 1911 microseconds (creates a C) */
   digitalWrite(piezoPin,LOW);
   /* stops sending 5V to the piezo speaker */
   delayMicroseconds(1911);
   /* waits for another 1911 microseconds */
  }
  if(digitalRead(keyTwo) == LOW){
  /* tests if the second soft button is pushed */
   digitalWrite(piezoPin,HIGH);
   /* sends 5V to the piezo speaker */
   delayMicroseconds(1703);
   /* waits for 1703 microseconds (creates a D) */
   digitalWrite(piezoPin,LOW);
   /* stops sending 5V to the piezo speaker */
   delayMicroseconds(1703);
   /* waits for another 1703 microseconds */
  }
  if(digitalRead(keyThree) == LOW){
  /* tests if the third soft button is pushed */
   digitalWrite(piezoPin,HIGH);
   /* sends 5V to the piezo speaker */
   delayMicroseconds(1517);
   /* waits for 1517 microseconds (creates an E) */
   digitalWrite(piezoPin,LOW);
   /* stops sending 5V to the piezo speaker */
   delayMicroseconds(1517);
   /* waits for another 1517 microseconds */
  }
  if(digitalRead (keyFour) == LOW){
  /* tests if the fourth soft button is pushed */
   digitalWrite(piezoPin,HIGH);
   /* sends 5V to the piezo speaker */
   delayMicroseconds(1432);
   /* waits for 1432 microseconds (creates an F) */
   digitalWrite(piezoPin,LOW);
   /* stops sending 5V to the piezo speaker */
   delayMicroseconds(1432);
   /* waits for another 1432 microseconds */
  }
  if (digitalRead(keyFive) == LOW){
  /* tests if the fifth soft button is pushed */
   digitalWrite(piezoPin,HIGH);
   /* sends 5V to the piezo speaker */
   delayMicroseconds(1276);
   /* waits for 1276 microseconds (creates a G) */
   digitalWrite(piezoPin,LOW);
   /* stops sending 5V to the piezo speaker */
   delayMicroseconds(1276);
   /* waits for another 1276 microseconds */
  }
}