Datasheet
The example will cause the HaloHD to display a rotating
rainbow pattern.
Note: The neopixel and microbit pin8 imports are
required for this program.
First, the number of LEDs and which pin the LEDs are
connected to are declared.
Next, the red, green and blue variables are all set to a
value from 0-240 (although the colours of the LEDs can
go to 255, 240 can be divided by 60, so each LED will
have an even colour difference).
Next, a flag for each colour is set to indicate if the value
needs to be increased or decreased. This is changed
when the particular colour value reaches 0 or 240.
The red, green and blue values are set for the LED and
then the show function is called to send it to the LED.
This operation is carried out within a for loop, so the
next time round in the loop it addresses the next LED
until all 60 LEDs have had their colour values set.
Once complete, the loop will start again, but this time
with the colour offset. The LEDs will change slightly,
giving the impression of the spectrum of colours
moving round the LEDs.
For more examples visit the Kitronik website at:
http://www.kitronik.co.uk/halohd
™Halo HD Board for the BBC micro:bit
www.kitronik.co.uk/5672
MicroPython Editor Code
if b == 240:
bCount = "minus"
elif b == 0:
bCount = "plus"
if rCount == "plus":
r = r + 6
else:
r = r - 6
if gCount == "plus":
g = g + 6
else:
g = g - 6
if bCount == "plus":
b = b + 6
else:
b = b - 6
zip_leds[zip] = (r, g, b)
zip_leds.show()
from microbit import pin8
import neopixel
# Declare constants
LEDS_ON_HALO = 60
zip_leds = neopixel.NeoPixel(pin8, LEDS_ON_HALO)
r = 240
g = 120
b = 0
zip = 0
rCount = "minus"
gCount = "minus"
bCount = "plus"
while True:
for zip in range(60):
if r == 240:
rCount = "minus"
elif r == 0:
rCount = "plus“
if g == 240:
gCount = "minus"
elif g == 0:
gCount = "plus"




