用户:
刘骏森查看:0 回复:0 评论:0 创建时间:2022-06-30T17:16:02
【作品展示】

【作品介绍】
优化了上一个版本的代码
【作品源代码】
from microbit import *
import radio
radio.on()
radio.config(channel=6)
display.scroll('start... A:turn on all the LEDs B:shoot pin0:send SOS pin1:send OK.')
shoot_list = [Image('00000:00000:00000:00000:00000'), Image('00000:00000:00009:00000:00000'), Image('00000:00009:00099:00009:00000'), Image('00009:00090:00999:00090:00009'), Image('00090:00900:09999:00900:00090'), Image('00900:09000:99999:09000:00900'), Image('09000:90000:99990:90000:09000'), Image('90000:00000:99900:00000:90000'), Image('00000:00000:99000:00000:00000'), Image('00000:00000:90000:00000:00000')]
while True:
if button_a.is_pressed():
display.show(Image('99999:99999:99999:99999:99999'))
elif button_b.is_pressed():
display.show(shoot_list, delay=100, wait=True, loop=False, clear=True)
elif pin0.is_touched():
display.scroll('Sending...')
radio.send('SOS')
elif (radio.receive() == 'SOS'):
display.scroll('SOS')
elif pin1.is_touched():
display.scroll('Sending...')
radio.send('OK')
elif (radio.receive() == 'OK'):
display.scroll('OK')
else:
display.clear()
# microbitweeemake
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn