上传新文件

上级 08f1b921
from machine import PWM,Pin
import utime
beep=PWM(Pin(25),freq=0,duty=100)
beep.deinit()
tone_list=[]
def playsong(tempo,tonelist):
beep.init()
per=60/tempo
tone_list={'c':(16,33,65,131,262,523,1046,2093,4186),
'cs':(17,35,69,139,277,554,1109,2217,4435),
'd':(18,37,73,147,294,587,1175,2349,4699),
'ds':(19,39,78,156,311,622,1245,2489,4978),
'e':(21,41,82,165,330,659,1319,2637,5274),
'f':(22,44,87,175,349,698,1397,2794,5588),
'fs':(23,46,93,185,370,740,1480,2960,5920),
'g':(25,49,98,196,392,784,1568,3136,6272),
'gs':(26,52,104,208,415,831,1661,3322,6645),
'a':(28,55,110,220,440,880,1760,3520,7040,),
'as':(29,58,117,233,466,932,1864,3729,7459),
'b':(31,62,123,247,493,988,1976,3951,7902),
's':(31,62,123,247,493,988,1976,3951,7902)}
for note in tonelist:
beep.freq(tone_list[note[0]][note[1]])
utime.sleep(per*note[2])
beep.deinit()
twotiger=[('c',4,1),('d',4,1),('e',4,1),('c',4,1),('d',4,1),('g',4,1),('g',4,1),('s',0,1), #两只老虎爱跳舞
('e',4,1),('a',4,0.5),('a',4,0.5),('a',4,1),('a',4,1),('g',4,0.5),('e',4,0.5),('g',4,1),('e',4,1), ('s',0,1), #小兔子乖乖拔萝卜~
]
supermario=[('e',4,0.25),('e',4,0.5),('e',4,0.5),('c',4,0.25),('e',4,0.5),('g',4,1),('g',3,1),
('c',4,0.75),('g',3,0.75),('e',3,0.75),('a',3,0.5),('b',3,0.5),('as',3,0.25),('a',3,0.5),
('g',3,0.25),('e',4,0.5),('g',4,0.25),('a',4,0.5),('f',4,0.25),('g',4,0.5),('e',4,0.5),('c',4,0.25),('d',4,0.25),('b',3,0.75),
('c',4,0.75),('g',3,0.75),('e',3,0.75),('a',3,0.5),('b',3,0.5),('as',3,0.25),('a',3,0.5),
('g',3,0.25),('e',4,0.5),('g',4,0.25),('a',4,0.5),('f',4,0.25),('g',4,0.5),('e',4,0.5),('c',4,0.25),('d',4,0.25),('b',3,0.75), #
('s',0,0.5),('g',4,0.25),('fs',4,0.25),('f',4,0.25),('ds',4,0.5),('e',4,0.5),('g',3,0.25),('a',3,0.25),('c',4,0.5),('a',3,0.25),('c',4,0.25),('d',4,0.25),
('s',0,0.5),('g',4,0.25),('fs',4,0.25),('f',4,0.25),('ds',4,0.5),('e',4,0.5),('c',5,0.5),('c',5,0.25),('c',5,0.5),#
('s',0,0.5),('g',4,0.25),('fs',4,0.25),('f',4,0.25),('ds',4,0.5),('e',4,0.5),('g',3,0.25),('a',3,0.25),('c',4,0.5),('a',3,0.25),('c',4,0.25),('d',4,0.25),
('s',0,0.5),('ds',4,0.75),('d',4,0.75),('c',4,1),('s',0,1),
('c',4,0.25),('c',4,0.5),('c',4,0.5),('c',4,0.25),('d',4,0.5),('e',4,0.25),('c',4,0.5),('a',3,0.25),('g',3,1),
('c',4,0.25),('c',4,0.5),('c',4,0.5),('c',4,0.25),('d',4,0.25),('e',4,0.55),('s',0,1.75),
('c',4,0.25),('c',4,0.5),('c',4,0.5),('c',4,0.25),('d',4,0.5),('e',4,0.25),('c',4,0.5),('a',3,0.25),('g',3,1),
('e',4,0.25),('e',4,0.5),('e',4,0.5),('c',4,0.25),('e',4,0.5),('g',4,1),('g',3,1),
]
playsong(105,supermario) #速度,歌谱
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册