const int buzzerPin = 5;
const int songLength = 34;
char notes[] = "fefefcDzAEAq Acz fefefcDzAEAq EzcA";
int beats[] = {1,1,1,1,1,1,1,1,4,1,1,3,1,1,1,3,1,1,1,1,1,1,1,1,1,4,1,1,3,1,1,1,1,3};
int tempo = 150;

void setup(){
  pinMode(buzzerPin, OUTPUT);
}

void loop(){
  int i, duration;
  
  for (i = 0; i < songLength; i++){
    duration = beats[i] * tempo;  
    
    if (notes[i] == ' '){
      delay(duration);            
    }
    else{
      tone(buzzerPin, frequency(notes[i]), duration);
      delay(duration);
    }
    delay(tempo/10);
  }
  while(true){}
}

int frequency(char note){  
  int i;
  const int numNotes = 11;
  char names[] = {'E','Q','A','B','c', 'q','z', 'd', 'D', 'e', 'f'};
  int frequencies[] = {175, 185, 233, 247, 258, 262, 277, 294, 311, 330, 349};
  
  for (i = 0; i < numNotes; i++){
    if (names[i] == note){
      return(frequencies[i]);
    }
  }
  return(0);
}