用户:
0423545385查看:0 回复:0 评论:0 创建时间:2021-06-26T14:15:33
嗨,又见面了
有些人想知道microbit的引脚功能,今天就来一个实例程序把
运行效果:
触摸引脚0,显示笑脸;引脚1显示正常,引脚2哭脸
首先启动microbit库
from microbit import *
制作引脚0的效果:
while True:
if pin0.is_touched():
display.show(Image('00000:09090:00000:90009:09990'))
else:
display.clear()
意为:
如果引脚0被触摸,则显示('00000:09090:00000:90009:09990')(笑脸),否则清空屏幕。
引脚1:while True:
if pin0.is_touched():
display.show(Image('00000:09090:00000:90009:09990'))
elif pin1.is_touched():
display.show(Image('00000:09090:00000:09990:00000'))
else:
display.clear()
意为前相近
引脚2:
while True:
if pin0.is_touched():
display.show(Image('00000:09090:00000:90009:09990'))
elif pin1.is_touched():
display.show(Image('00000:09090:00000:09990:00000'))
elif pin2.is_touched():
display.show(Image('00000:09090:00000:09990:90009'))
else:
display.clear()
拜拜啦