piano code
This commit is contained in:
parent
c71350b6bc
commit
d67087a37d
4 changed files with 21 additions and 0 deletions
20
piano.py
Normal file
20
piano.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
from time import sleep
|
||||
from telemetrix_rpi_pico import telemetrix_rpi_pico
|
||||
import winsound
|
||||
|
||||
index_shift = 2
|
||||
sound = [261.6256,293.6648,329.6276,349.2282,391.9954,440.0000,493.8833,523.2511]
|
||||
|
||||
def handle_button_press(data):
|
||||
freq = sound[data[1]-index_shift]
|
||||
print(freq)
|
||||
if data[2] == 0:
|
||||
winsound.Beep(int(freq),500)
|
||||
|
||||
|
||||
|
||||
mcu = telemetrix_rpi_pico.TelemetrixRpiPico(com_port='COM10')
|
||||
for i in range(2,10):
|
||||
mcu.set_pin_mode_digital_input(i,callback=handle_button_press)
|
||||
while True:
|
||||
sleep(100)
|
BIN
piano/__pycache__/piano.cpython-310.pyc
Normal file
BIN
piano/__pycache__/piano.cpython-310.pyc
Normal file
Binary file not shown.
BIN
piano/__pycache__/tone.cpython-310.pyc
Normal file
BIN
piano/__pycache__/tone.cpython-310.pyc
Normal file
Binary file not shown.
1
requirements.txt
Normal file
1
requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
telemetrix-rpi-pico
|
Loading…
Add table
Add a link
Reference in a new issue