#include "pitches.h"

const int outPin = D0; //output to buzzer
const int duration = 500; //how long noise is made

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

void loop() {
  if (Serial.available() > 0) { // Check if any data is available in the serial buffer
    char note = Serial.read(); // Read the character from the serial buffer

    //play note gotten from user
    switch(note){
      case 'c':
        tone(outPin, NOTE_C4, duration);
        break;

      case 'D':
        tone(outPin, NOTE_D4, duration);
        break;

      case 'E':
        tone(outPin, NOTE_E4, duration);
        break;

      case 'F':
        tone(outPin, NOTE_F4, duration);
        break;

      case 'G':
        tone(outPin, NOTE_G4, duration);
        break;

      case 'A':
        tone(outPin, NOTE_A4, duration);
        break;

      case 'B':
        tone(outPin, NOTE_B4, duration);
        break;

      case 'C':
        tone(outPin, NOTE_C5, duration);
        break;

      default:
        tone(outPin, NOTE_B0, duration);
        break;
    }  
  }
  delay(100);
}