Dimmer Switch


This lesson challenges students to incorporate both push and variable switches to control the micro:bit’s LED matrix. Students will have to convert the analog values from a potentiometer into an acceptable value that controls the LED matrix.


  • Create two variables that work in conjunction with each other.
  • Use an analog reading to control the brightness of the micro:bit LED matrix.

Download the Code

MakeCode Editor

Click the button below to download the MakeCode editor code for this lesson. The hex file is contained in a zip folder.

Kindly refer to our download the code page for instructions on how to upload your code onto the micro:bit. Please use instructions set A.

This code can also be uploaded into the MakeCode editor.

Kit Required


Innovation Board


- 1 x Connector Cables


  1. Connect the micro:bit to the Innovation board via the edge connector.
  2. Use the connector cables to connect the potentiometer to the ADC1 connector on the Innovation board.
  3. Connect the micro:bit to a computer via the microUSB cable.
  4. Go to the MakeCode website on your computer and open a new project.

Time to Code

What Will Happen

When button A is pressed the LED matrix will be activated. The potentiometer can be used to vary the brightness level of the LEDs. Turn the potentiometer clockwise to brighten the LEDs and anti-clockwise to dim the LEDs. To turn off the LED matrix press button A.

Taking it Further

  • Incorporate more devices into the system. Look to use an LED board instead of the micro:bit.

Keep in Touch

We would love to keep in touch with you and as a result aid you along your digital making journey.

Becoming a digital maker subscriber means you will receive exclusive offers and we will keep you up to date with new resources and kits, as well as upcoming events and workshops.

Let us know how your digital education journey is progressing. Send us pictures and videos of your awesome creations and use the hashtag below.