Skip to content

Commit 243ae61

Browse files
Add draft code
1 parent 02289c0 commit 243ae61

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

draft_code/buzzer.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from machine import Pin, PWM
2+
import time
3+
4+
# Set up pin 46 as PWM output
5+
buzzer = PWM(Pin(46))
6+
7+
# Function to play a tone (frequency in Hz, duration in seconds)
8+
def play_tone(frequency, duration):
9+
buzzer.freq(frequency) # Set frequency
10+
buzzer.duty_u16(32768) # 50% duty cycle (32768 is half of 65536)
11+
time.sleep(duration) # Play for specified duration
12+
buzzer.duty_u16(0) # Stop the tone
13+
14+
# Example: Play a 440 Hz tone (A4 note) for 1 second
15+
play_tone(440, 1)
16+
17+
# Optional: Play a sequence of notes
18+
notes = [(261, 0.5), (293, 0.5), (329, 0.5), (349, 0.5)] # C4, D4, E4, F4
19+
for freq, duration in notes:
20+
play_tone(freq, duration)
21+
time.sleep(0.1) # Short pause between notes
22+
23+
# Turn off the buzzer
24+
buzzer.deinit()

internal_filesystem/apps/com.quasikili.kilculator

Lines changed: 0 additions & 1 deletion
This file was deleted.

internal_filesystem/boot_fri3d-2024.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
# Pin configuration
2323
SPI_BUS = 2
24-
SPI_FREQ = 40000000
25-
#SPI_FREQ = 20000000 # also works but I guess higher is better
24+
#SPI_FREQ = 40000000
25+
SPI_FREQ = 20000000 # also works but I guess higher is better
2626
LCD_SCLK = 7
2727
LCD_MOSI = 6
2828
LCD_MISO = 8

0 commit comments

Comments
 (0)