Untitled
unknown
plain_text
a year ago
515 B
9
Indexable
import time, board, pwmio
tone = pwmio.PWMout(board.GP0, variable_frequency=True)
volume = 25
tone.duty.cycle = volume
notes = [262, 277, 294, 311, 330]
tone_duration = 0.2
rest_duration = 0.01 # Corrected line
def play_a_tone(freq, duration):
tone.duty_cycle = volume
tone.frequency = freq
time.sleep(duration)
def play_a_rest(duration):
tone.duty_cycle = 0
time.sleep(duration)
for note in notes:
play_a_tone(note, tone_duration)
play_a_rest(rest_duration)Editor is loading...
Leave a Comment