5863| 3
|
[高级教程] 用python编写“micro:bit环形RGB灯扩展板”彩虹色渐变特效 |
本帖最后由 牧之 于 2018-8-6 15:21 编辑 使用硬件:micro:bit环形RGB灯扩展板 DFRobot Micro:bit Circular RGB Expansion board 使用编程软件:uPyCraft V1.0 彩虹色渐变函数rainbow(t)的定义及其调用: [mw_shl_code=python,true]from microbit import * import neopixel np = neopixel.NeoPixel(pin2, 24) def rainbow(t): r=100 g=0 b=0 for c in range(0,50): g=g+2 for i in range(0,24): np = (r,g,b) np.show() sleep(t) for c in range(0,50): r=r-2 for i in range(0,24): np = (r,g,b) np.show() sleep(t) for c in range(0,50): b=b+2 for i in range(0,24): np = (r,g,b) np.show() sleep(t) for c in range(0,50): g=g-2 for i in range(0,24): np = (r,g,b) np.show() sleep(t) for c in range(0,50): r=r+2 for i in range(0,24): np = (r,g,b) np.show() sleep(t) for c in range(0,50): b=b-2 for i in range(0,24): np = (r,g,b) np.show() sleep(t) while True: rainbow(50)[/mw_shl_code] |
© 2013-2025 Comsenz Inc. Powered by Discuz! X3.4 Licensed