'''
 * Filename    : Passive buzzer
 * Thonny      : Thonny 4.1.4
 * Auther      : http//www.keyestudio.com
'''
from machine import Pin, PWM
import time

buzzer = PWM(Pin(3))

'''
-----------------------------
| Pitch names |  Frequency  |
|---------------------------|
|      C      |     523     |
|      D      |     587     |
|      E      |     659     |
|      F      |     698     |
|      G      |     784     |
|      A      |     880     |
|      B      |     988     |
-----------------------------
'''
a = [523,587,659,698,784,880,988]

while True:
    #the tone when the duty cycle = 1000
    for i in a:
        buzzer.duty_u16(1000)
        buzzer.freq(i)
        time.sleep(0.2)
    #the tone when the duty cycle = 5000
    for i in a:
        buzzer.duty_u16(5000)
        buzzer.freq(i)
        time.sleep(0.2)