Lesson 1 – Lighting Up The Christmas Tree
With the Rainbow Tree board (and a micro:bit of-course) you can light up your own Christmas tree is many different colors. The Rainbow tree offers an easy electronics challenge for those wanting to play around with the BBC micro:bit and dabble with some simple circuits to get the feel of electronics and interact with the real world. The Rainbow Tree is a simple circuit in the shape of a Christmas tree with 6 multi color LED’s on it. Wire up the Rainbow Tree, connect it up to your BBC micro:bit, put together the code and light it up in an array of colors.
The BBC micro:bit has grown in popularity over the years. The micro:bit might be small electronics board but it’s packed with features (e.g. LED’s, accelerometer, temperature sensor, light sensor, compass, etc.) offering kids of all ages the opportunity to get started with their STEM (Science, Technology, Engineering, Math) learning journey. Kids can use the BBC micro:bit board to get started with coding, later on start dabbling with electronics and eventually try their hand at robotics all using the same little electronics board.
What do you need – Here’s the list of components you will need for this tutorials –
- 1 x Christmas Tree Rainbow LED
- 3 x Crocodile clips connectors
- 1 x BBC micro:bit
Let’s set it up – Before we can start programming the BBC micro:bit let’s spend sometime and wire up all the relevant connections on the board.
- Connect the black crocodile clip line to the GND port of the micro:bit, the other side of the black crocodile clip line to the G port of the Christmas tree rainbow LED.
- Connect the red crocodile clip line to the 3V port of the micro:bit, the other side of the red crocodile clip line to the V port of the Christmas tree rainbow LED.
- Connect the yellow crocodile clip line to the 0 port of the micro:bit, the other side of the yellow crocodile clip line to the S port of the Christmas tree rainbow LED.
Writing the code –
Step 1 – Before we can start writing the code we need to load some relevant BBC micro:bit libraries. So head over to – https://makecode.microbit.org/#
Click on “New Project” and create a new Project.
Step 2 – Then click on “Advanced” for more code blocks and click on “Extensions” at the bottom.
Step 3 – Search for “neopixel” and add the “neopixel” library.
Step 4 – We are now ready to start writing code. Head over to your BBC MakeCode editor and add the following code as shown below.
Choose “set strip to neopixel at pin with leds as” from neopixel blocks. Set pin to P1 with 6 LEDs in RGB pattern.
Step 5 – Select the strip rotate block from the neopixel under the forever. Set the rotate pixels to 1 and set the LEDs change its color one by one. We will then select a “show” block which will light up the neopixels.
Step 6 – Here’s what your final project should look like –
Check out the code at – https://makecode.microbit.org/_MMcHh7AjY97M