From eb2799fe2ef4a466221a412b40fa3b054ba433e8 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Fri, 14 Nov 2025 12:48:13 +0100 Subject: [PATCH] Remove draft_code/buzzer.py --- draft_code/buzzer.py | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 draft_code/buzzer.py diff --git a/draft_code/buzzer.py b/draft_code/buzzer.py deleted file mode 100644 index d21a1ead..00000000 --- a/draft_code/buzzer.py +++ /dev/null @@ -1,24 +0,0 @@ -from machine import Pin, PWM -import time - -# Set up pin 46 as PWM output -buzzer = PWM(Pin(46)) - -# Function to play a tone (frequency in Hz, duration in seconds) -def play_tone(frequency, duration): - buzzer.freq(frequency) # Set frequency - buzzer.duty_u16(32768) # 50% duty cycle (32768 is half of 65536) - time.sleep(duration) # Play for specified duration - buzzer.duty_u16(0) # Stop the tone - -# Example: Play a 440 Hz tone (A4 note) for 1 second -play_tone(440, 1) - -# Optional: Play a sequence of notes -notes = [(261, 0.5), (293, 0.5), (329, 0.5), (349, 0.5)] # C4, D4, E4, F4 -for freq, duration in notes: - play_tone(freq, duration) - time.sleep(0.1) # Short pause between notes - -# Turn off the buzzer -buzzer.deinit()