diff --git a/piano.py b/piano.py new file mode 100644 index 0000000..3c599cc --- /dev/null +++ b/piano.py @@ -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) \ No newline at end of file diff --git a/piano/__pycache__/piano.cpython-310.pyc b/piano/__pycache__/piano.cpython-310.pyc new file mode 100644 index 0000000..f6f2a13 Binary files /dev/null and b/piano/__pycache__/piano.cpython-310.pyc differ diff --git a/piano/__pycache__/tone.cpython-310.pyc b/piano/__pycache__/tone.cpython-310.pyc new file mode 100644 index 0000000..36d5811 Binary files /dev/null and b/piano/__pycache__/tone.cpython-310.pyc differ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..fca2e79 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +telemetrix-rpi-pico \ No newline at end of file