Arduino Music

By Examples
int noteDuration = 3;

int numNotes = 16;

int notes[] = {
  NOTE_B2,
  NOTE_FS4,
  NOTE_B2,
  NOTE_B4,
  
  NOTE_B2,
  NOTE_D5,
  NOTE_B2,
  NOTE_CS5,
  
  NOTE_B2,
  NOTE_A4,
  NOTE_B2,
  NOTE_FS4,
  
  NOTE_B2,
  NOTE_A4,
  NOTE_B2,
  NOTE_B4,
};

void setup()
{
  Serial.begin(9600);
  pinMode(12, INPUT); 
}

int i = 0;
void loop()
{
  Serial.println(notes[i]);
  if (notes[i])
    tone(noteDuration, notes[i]);
  else
    noTone(noteDuration);
  delay(200);
  i = (i + 1) % numNotes;
}