樍木程式如下:
Python程式如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | def on_button_pressed_a(): global go go = 0 input.on_button_pressed(Button.A, on_button_pressed_a) def on_button_pressed_b(): global go go = 1 input.on_button_pressed(Button.B, on_button_pressed_b) go = 0 strip = neopixel.create(DigitalPin.P0, 16, NeoPixelMode.RGB) strip.clear() strip.show() basic.show_icon(IconNames.HEART) def on_every_interval(): basic.show_string("Happy New Year!") loops.every_interval(10000, on_every_interval) def on_forever(): if go == 1: for indeks in range(17): strip.clear() strip.set_pixel_color(indeks, neopixel.rgb(randint(0, 255), randint(0, 255), randint(0, 255))) strip.show() basic.pause(10) basic.forever(on_forever) |
沒有留言:
張貼留言