From d67087a37d879de89be782786e6e055733e018cd Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Fri, 8 Apr 2022 18:30:22 +0700 Subject: [PATCH] piano code --- piano.py | 20 ++++++++++++++++++++ piano/__pycache__/piano.cpython-310.pyc | Bin 0 -> 756 bytes piano/__pycache__/tone.cpython-310.pyc | Bin 0 -> 1460 bytes requirements.txt | 1 + 4 files changed, 21 insertions(+) create mode 100644 piano.py create mode 100644 piano/__pycache__/piano.cpython-310.pyc create mode 100644 piano/__pycache__/tone.cpython-310.pyc create mode 100644 requirements.txt 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 0000000000000000000000000000000000000000..f6f2a1367a06364bd185c6059c1960f60ed54648 GIT binary patch literal 756 zcmYjPOK%e~5VpPEW;dI(fnE|g^#E-yDIiW2LMs&k2Obs8X;rk^#O~JZzT)*tsR$4$ z9O)T}6A!5pKLGJVxb1-p2b2SUfJ+!}5UM4A8qe6@%zWdt*{ma2?;3l9O@h!*eYm(x zIJmI$1b`uiBNSr~V{Ma&#Ka?&ZA3;)JqkAU%n&j26ZTfv3ah(V=vH@i4mnX5mu4Puo`JEhc*J9_q!{}$ z6MiO!DY$7rP52zjM_ns)?q4g2m$_m4`o8(ulWsWMeso@cuiS8J&G~x%y>LVN>+RO> z*JC%-3DER~8_pm078^fax#8{UHJ|E(!9k0 literal 0 HcmV?d00001 diff --git a/piano/__pycache__/tone.cpython-310.pyc b/piano/__pycache__/tone.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..36d581157a69c2988245af8e5b57c02b0a32e538 GIT binary patch literal 1460 zcmaJ>OK%)S5bo~jd2QAPLI9EEFh~exIam=nv9b)2BEo5935&zX(Wo=sYmb?o8F%+W z*4mXoj%0Iy-{3vwFZGp^Z%A-Lh)^|~eMCf*R5evy)!)=>rrz4>5TIw>{ipwMLViPI zlRPlK1U8?7kVMjwq>Cp_X=}5TJtmS#?>Uj)IZHiBzac$-4e?}Uo?jz7I zeCF8ztxI-?oYNV%!6lorTd4bzqvsC!nO=|!dclUC^kwiovf-4U(?=K+$nYwX5uB1~ zfG2Z03&HQB|4BHDrruRN4d;}S)6YTg%n2njhQvGKeM(3tc}4rBn3%*uDaldsy{Zy> ztdd4(F*2)|erqQ~txm_P$|wC~P+PUOlcGw#K3j*|NweYYC&RK9cI{rEiBVG)b}Ust zdAL;9F)hSK$QvQ#SPNU!RX=(3N=xctTR?^RK~_fPbtN|{`G4GN=nOgNaTg40JrXvJ z@?%j|sx&EwS1A|NW7~}F5rhH#{zZ-#mc&58$v*%#_d)zbrsT=HGkOU-a0M#`Q-uj% z0#7MCf#<;A!emZi*6~rW=jd<%#RSIcac&)NME+fm zY5dqzZlE&#HmD2n4r(_++ygf77l2G}LvwCuY?7mm<8`Ad7d8_ymPMV$jra;T?ZIb` z4UO}P$~s?*>PR_$QbQ;GA9Mjj^z*Vdsu%0G07q{jShQTFHZ>(ijt(3>a2y-qxD;0C z8yMZD*F_D}bMdNM=rsw5V2e{mk%PatgD&mRZ646z`%fHmc>gM7^73r(;nrJo+|Z>kmPs;r`?y7OX!2%XN)~k02i@dt6KX2}Z4Z*lKMf vm&<9e*Ad|?qKs|RwwFDwL%jDM3VcO-`X(3`?Jm;W!^LmcCn6Dz=uPimNYGun literal 0 HcmV?d00001 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