美文网首页
从MakeCode到Python

从MakeCode到Python

作者: 少儿创客 | 来源:发表于2017-12-29 22:57 被阅读738次

转发请注明作者。

跳动的心

from microbit import *
while True:
    display.show(Image.HEART)
    sleep(100)
    display.show(Image.HEART_SMALL)
    sleep(100)

自定义图形

makecode

在makecode图形化界面里,可以用点击的方式来自定义图形


图形界面自定义

在python编程方式下也是可以自定义,但是要对led点阵有足够的了解.

python方式

image = Image("90009:"
              "09090:"
              "00900:"
              "09090:"
              "90009")
# 或者用换行符
image = Image("90009\n"
              "09090\n"
              "00900\n"
              "09090\n"
              "90009")

display.show(image)

Smiley Buttons微笑按钮

当按钮A被按的时候,屏幕显示开心图像

from microbit import *

while True:
    if button_a.is_pressed():
        display.show(Image.HAPPY)

当按钮A被按的时候,屏幕显示开心图像

from microbit import *

while True:
    if button_b.is_pressed():
        display.show(Image.SAD)

当按钮A+B被按的时候,屏幕显示开心图像

from microbit import *

while True:
    if button_a.is_pressed() and button_b.is_pressed():
        display.show(Image.HAPPY)
        display.show(Image.SAD)
display.clear()

相关文章

网友评论

      本文标题:从MakeCode到Python

      本文链接:https://www.haomeiwen.com/subject/dajwgxtx.html