Skip to content

Instantly share code, notes, and snippets.

@honno
Last active September 22, 2023 13:51
Show Gist options
  • Save honno/7932397c6d23c640e0b5ed723588f995 to your computer and use it in GitHub Desktop.
Save honno/7932397c6d23c640e0b5ed723588f995 to your computer and use it in GitHub Desktop.
microbit.py
from microbit import *
import audio
import math
import neopixel
nps = [neopixel.NeoPixel(pin0, i, bpp=3) for i in range(1,10)]
current_np = 0
while True:
if button_a.is_pressed() or button_b.is_pressed():
for _ in range(100):
audio.play(Sound.HELLO)
np = nps[current_np]
np[0] = (255, 0, 128) # first element
np[-1] = (0, 255, 0) # last element
np.show() # only now will the updated value be shown
current_np += 1
if current_np == 9:
current_np = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment