#include <Arduino.h>

const uint8_t BUZZER_PIN = 8;  // Signal goes to the transistor driver.
// This array holds eight note frequencies in hertz (cycles per second).
const unsigned int NOTES_HZ[] = {523, 587, 659, 698, 784, 880, 988, 1047};

// No special pin configuration is needed here; tone() configures the output.
void setup() {}

// Play each frequency, then pause before starting the tune again.
void loop() {
  // The index note goes from 0 to 7, selecting one element of NOTES_HZ.
  for (uint8_t note = 0; note < 8; ++note) {
    // tone() generates the chosen pitch for about 500 milliseconds.
    tone(BUZZER_PIN, NOTES_HZ[note], 500);
    // Wait one second between note starts, leaving space between notes.
    delay(1000);
  }
  // Rest two seconds after the last note.
  delay(2000);
}
