一个简单的水波纹效果的动画,使用5X5 LED点阵进行显示。
三种不同的显示方法
程序一:
from microbit import *
ripple1 = Image('00000:00000:00900:00000:00000:')
ripple2 = Image('00000:00900:09690:00900:00000:')
ripple3 = Image('00900:09690:96369:09690:00900:')
ripple4 = Image('09690:96369:60006:96069:09690:')
ripple5 = Image('96369:63036:30003:63036:96369:')
ripple6 = Image('63036:30003:00000:30003:63036:')
ripple7 = Image('30003:00000:00000:00000:30003:')
ripple8 = Image('00000:00000:00000:00000:00000:')
while True:
display.show(ripple1)
sleep(100)
display.show(ripple2)
sleep(100)
display.show(ripple3)
sleep(100)
display.show(ripple4)
sleep(100)
display.show(ripple5)
sleep(100)
display.show(ripple6)
sleep(100)
display.show(ripple7)
sleep(100)
display.show(ripple8)
sleep(1000)
程序二:
from microbit import *
ripple1 = Image('00000:00000:00900:00000:00000:')
ripple2 = Image('00000:00900:09690:00900:00000:')
ripple3 = Image('00900:09690:96369:09690:00900:')
ripple4 = Image('09690:96369:60006:96069:09690:')
ripple5 = Image('96369:63036:30003:63036:96369:')
ripple6 = Image('63036:30003:00000:30003:63036:')
ripple7 = Image('30003:00000:00000:00000:30003:')
ripple8 = Image('00000:00000:00000:00000:00000:')
#创建列表
ripple=[ripple1,ripple2,ripple3,ripple4,ripple5,ripple6,ripple7,ripple8]
def showRipple(delay):
while True:
for i in ripple:
display.show(i)
sleep(delay)
sleep(1000)
if __name__=='__main__':
showRipple(100)
程序三:
from microbit import *
ripple1 = Image('00000:00000:00900:00000:00000:')
ripple2 = Image('00000:00900:09690:00900:00000:')
ripple3 = Image('00900:09690:96369:09690:00900:')
ripple4 = Image('09690:96369:60006:96069:09690:')
ripple5 = Image('96369:63036:30003:63036:96369:')
ripple6 = Image('63036:30003:00000:30003:63036:')
ripple7 = Image('30003:00000:00000:00000:30003:')
ripple8 = Image('00000:00000:00000:00000:00000:')
all_ripples = [ripple1, ripple2, ripple3, ripple4, ripple5, ripple6, ripple7, ripple8]
while True:
display.show(all_ripples, delay=100)
sleep(1000)