Fixed typo
[one-dimensional-fireworks.git] / fireworks1.py
1 from microbit import *
2 import neopixel
3
4 NP_COUNT = 60
5 BURST_SIZE = 10
6
7 np = neopixel.NeoPixel(pin0, NP_COUNT)
8
9 BLUE = (0, 0, 64)
10 RED = (64, 0, 0)
11 OFF = (0, 0, 0)
12
13
14 def reset(pixels):
15 for n in range(NP_COUNT):
16 pixels[n] = OFF
17 pixels[0] = BLUE
18 np.show()
19
20 def shoot_firework(pixels):
21 for pixel in range(NP_COUNT - BURST_SIZE):
22 pixels[pixel] = RED
23 pixels.show()
24 sleep(20)
25 pixels[pixel] = OFF
26 pixels.show()
27
28
29 reset(np)
30
31 while True:
32 if button_a.is_pressed():
33 # set off a firework
34 shoot_firework(np)
35 reset(np)