Example Code for micro:bit-Control the Circular Light via Key A, B

Turn on the power, then 24 RGB LEDs display some colors randomly in the beginning. When key A is pressed, executing the waterfall light mode once; When B is pressed, the circular light refreshes the color in every 20ms, and there are 7 colors at all.

Hardware Preparation

  • micro:bit main board ×1
  • ROB0150 24 RGB LEDs Circular Expansion Board ×1
    (Purchase Link)
  • USB cable ×1

Software Preparation

  1. Development Tool:
    MakeCode
    https://makecode.microbit.org

  2. Add the Neopixel Software Package
    Load the neopixel library to control the LED ring.

Other Preparation Work

Add the neopixel software package (loading the lamp ring library) in Makecode; the steps are as follows:

Add the software package

Sample Code

Click and enter the graphic programming: Control the Annular Light via Key A, B

Display colors randomly

Forward Waterfall Light

Reverse Waterfall Light

Result

  • Power on: 24 RGB LEDs display colors randomly.
  • Press key A: Executes waterfall light mode once.
  • Press key B: Circular light refreshes color every 20ms (7 colors total).

Control the Circular Light by Key A, B

Was this article helpful?

TOP