How it works?
When Button A is pressed, the 360 servo will start to turn anticlockwise, display rainbow colours and the mp3 will begin to play.
When Button AB is pressed, the servo will turn anticlockwise.
When B is pressed, the servo & mp3 will stop and the colours from the LEDs will be set to off.
On start will run once the micro:bit is powered on.
We set a variable light and inform micro:bit how many RGB leds are there.
The dfplayer will play the mp3 file when it receives a signal from the microbit via pin 1. As we do not need the dfplayer to send a signal back to the micro:bit, we do not need to connect pin 13 but we still need to specific in the program.
The volume from the dfplayer and the brightness of the LED pixels ring can be easily adjusted.
The leds are set to off.
Forever contains the instructions that get repeated over and over until the board is turned off.
We will show the lights and rotate by 1 pixel. Initially when we power on, the lights are set to off and thus nothing to show.
When Button A is pressed, the RGB ring will display rainbow colours. The forever loop will show the colours and rotate pixel by 1.
Since we are powering the dfplayer, led ring and 360 servo, we have to connect the power to the micromate instead of the micro:bit. If the servo is not turning, turn the voltage selector to 5v.
You can add pir to it so that the Christmas tree will respond when someone enters the room.