用户:没尾巴的鲸鱼查看:0 回复:0 评论:0 创建时间:2019-11-14T18:43:16
【作品展示】

【作品介绍】
闲得蛋疼时瞎做的
【作品源代码】
from microbit import *
import radio
import elfshield
#When starting up
for __count in range(6):
display.show('Loading...')
sleep(0.5)
display.show('Loading.. ')
sleep(0.5)
display.show('Loading. ')
sleep(0.5)
display.clear()
off_on()
while True:
if (temperature() >= 36):
display.clear()
display.off()
radio.reset()
radio.off()
reset()
off_on()
if (running_time() >= 36):
display.clear()
display.off()
radio.reset()
radio.off()
off_on()
reset()
if (button_a.is_pressed() and button_b.is_pressed()):
sleep(1)
if button_b.is_pressed():
while (not compass.is_calibrated()):
compass.calibrate()
sleep(50)
display.clear()
tmp1 = compass.heading()
display.show(tmp1)
while (not button_a.is_pressed()):
pass
display.clear()
tmp1 = compass.get_field_strength()
display.show(tmp1)
while (not button_a.is_pressed()):
pass
if (button_a.is_pressed() and button_b.is_pressed()):
sleep(1000)
if button_b.is_pressed():
off_on()
while (not button_a.is_pressed()):
display.show(tmp1)
if (elfshield.potentiometer_value(elfshield.PORT_A) > 10):
a = 10
elif (elfshield.potentiometer_value(elfshield.PORT_A) < 1):
a = 1
else:
a = elfshield.potentiometer_value(elfshield.PORT_A)
tmp1 = [a, 'A']
radio.on()
radio.reset()
radio.config(channel=a)
while (not button_a.is_pressed()):
display.show(tmp1)
if (elfshield.potentiometer_value(elfshield.PORT_B) > 10):
a = 10
elif (elfshield.potentiometer_value(elfshield.PORT_B) < 1):
a = 1
else:
a = elfshield.potentiometer_value(elfshield.PORT_B)
tmp1 = [a, 'B']
radio.send(a)
def sleep(time):
sleep(time * 1000)
def off_on():
display.show(Image('99999:99999:99999:99999:99999'))
y = 1
x = 1
for __count in range(5):
for __count in range(5):
display.set_pixel(x, y, 0)
x += 1
y += 1
x = 1
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn