First, use some croc-clip wires to connect the pads on the christmas tree to the pads with holes on the micro:bit edge connector. It is important to get the order right, and to avoid connecting also to the small pads between the main pads on the micro:bit. It doesn’t matter which colours you use, but normally 3V would be red, and 0V would be black.
- Pin 0 to SOUND
- Pin 2 to LED
- 3V to 3V
- GND to GND
Now you need some software. For a quick-start take this file directly from GitHub. Right click here and save-as (the file should be called tree.hex). Now plug your micro:bit into your PC, and copy the hex file to what looks like a flash storage device on your micro:bit. The yellow light should flash on the micro:bit as the file is transferred, this will take a couple of seconds. Now the program will start, and although the micro:bit display remains blank, the tree will have sound and light.
You can see the program (which is written in python) here on GitHub. We import both the neopixel module and the music module. These add extra functionality to the basic micro:bit, and they’re described here.
First, we initialise a neopixel on pin 2. This can drive several of the intelligent LEDs. They work in series over a single wire, and can be set to light each of Red, Green and Blue to different brightness. I am using 155 for each colour in turn which is a moderate brighness (255 is really too bright to look at safely).
Before starting to light the LEDs, we play the NYAN theme (non-blocking, so the program continues to run whilst the tune plays in the background).
We then cycle through all 5 LEDs and all 3 primary colours. Then we change the tune, and repeat.