# play_tones.py

# Demo for the Cytron Maker Pi Pico with Raspberry Pi Pico installed.
# Play a melody on the buzzer.

# This uses the tones module from the music/ folder of the course sample code.
# The tones.py file should be copied to the top level of the CIRCUITPY drive.

import board
import time

# load the speaker driver module
import tones

#---------------------------------------------------------------
# create an I/O object for the buzzer on GP18
speaker = tones.ToneSpeaker(board.GP18)

#---------------------------------------------------------------
# run forever
while True:
    # play a major C scale up and down
    for note in [60, 62, 64, 65, 67, 69, 71, 72, 71, 69, 67, 65, 64, 62, 60]:
        speaker.midi_tone(note)
        time.sleep(0.125)

    speaker.noTone()
    time.sleep(2.0)
