from machine import Pin, PWM from utime import sleep from time import sleep_ms from song import Song from buzzer import Buzzer, BuzzerLib bz = PWM(Pin(23)) # Programming the Buzzer bz.freq(500) # volumne = 500 bz.duty_u16(1000) sleep(1) bz.duty_u16(0) # Playing Music with a Buzzer _song = Song(23) _song.play_song_test() sleep(1) _song.play_song_mario() sleep(1) _song.play_song_jingle() # Other Lib bz = Buzzer(23) print("Playing mario.") bz.play(BuzzerLib.mario, 150, 32767) sleep_ms(1000) print("Playing jingle bells.") bz.play(BuzzerLib.jingle, 250, 32767) sleep_ms(1000) print("Playing twinkle, twinkle little star.") bz.play(BuzzerLib.twinkle, 600, 32767)