Micro:Bit Advent Calendar Day 05 - Control LED Brightness Using a Potentiometer


Need help for the Micro:Bit Advent Calendar Day 5 Guide (Control LED Brightness Using a Potentiometer)? Just post on this thread and our highly trained team of Micro:Bit ninjas will be able to help you in no time!


I’m confused about a couple of points:

  • Why do you write to P0 in the code, that’s the input from the potentiometer?
  • Aren’t Micro:Bit inputs only rated up to 4.2v maximum?

For the first point, I skipped writing to P0 and it works fine without that. It shouldn’t do any harm.

For the second point, in step 4 I connected potentiometer VCC to 3.3v (j13) and in step 9 I set the vcc variable to 3.3.

Here’s some information about the maximum voltages on the pins:

With these changes it works well. Thanks for the tutorial!


Hi Sean,

The code will work fine with it with or without it. Only ‘set sensorVal to analog read pin P0’ is needed to make the calculations.

No problem, thanks for your feedback!


Keep up the good work, guys!

Slight problem was evident on previous days, but is more of an issue today.

The plug-in peripherals are shown in the lovely animated instructions as if their pins have 90 degree bends. But the units, as supplied, have straight pins and do not appear long enough to be bent.

Today’s unit has the shaft of the potentiometer covering all the breadboard holes in cols 19 and 20, and the supplied jumper wires cannot be used.

I can easily reversed the potentiometer and the leads, but that may not be obvious for new starters?



I’ve noticed the same - and have put a 90 degree header into the board, so everything the kids are plugging in is sitting off the side of the board instead of sticking out of the top of the board, works well:

Like so:


I’ve used the male - female jumper leads to extend the modules away from the breadboard. Turning them around works too, but as you say, Rob, might be a bit confusing for beginners.
If I had a 90 degree header like Rendrag’s that would be much better! Maybe a worthwhile addition to future kits?


Myself and my 8 year old struggled with this one yesterday as well. As yet we still don’t have it working. Agree that the cables don’t fit because the Pot gets in the way (and that happened with the timer yesterday but we reversed everything to make it work without the cables being directly in the way of the timer display). Also the written instructions and the graphic don’t match up either. Here’s one example (and it’s happened on other days as well) …

Written instructions say this …

Finally, grab two 'analog write pin … ’ blocks:

'degrees' to Pins 0 (connected to the signal pin of potentiometer) 
and 'brightness' to Pin 2 (connected to positive leg of LED)

But the picture looks like this …

So which one is correct?

Also I notice that whenever I’m viewing the instructions my browser uses up heaps of CPU (enough to make the fans increase to almost maximum). Doesn’t matter which browser I use.

Think we need Rendrag’s 90 degree header as well.


Hi, sorry that it hasn’t worked for you yet!

The instructions from the graphic is correct.

Rendrag’s 90 degree header is definitely a great idea and a worthwhile addition to future kits.


@Rendrag are you able to give me a link to a 90 degree header like that please? Maybe at Jaycar? Would love to get one assuming the instructions work past Day 6!! Keep getting lost!!


Hmm, the closest thing I can find at Jaycar is this set: https://www.jaycar.com.au/arduino-stackable-header/p/HM3208 - then just bend the legs at 90 degrees :slight_smile:
LittleBird have the same kinda headers: https://www.littlebird.com.au/esp32-thing-stackable-header-set