
ZIP LEDs Experiment 10 - Using A Potentiometer To Control an LED:
In this experiment, firstly we light up a single LED and then we use a Potentiometer to control the speed that the lit LED spins around a ring.Parts List:
- A BBC micro:bit.
- 1 x 3 AA battery pack.
- A ZIP Ring - 12 LEDs.
- 1 x Terminal Connector.
- A Potentiometer & Finger Adjust Spindle.
- 2 x Male to Male Jumper Wires.
- 5 x Male to Female Jumper Wires.
The Aims Of This Experiment Are:
- Learn how control ZIP LED colours.
- Also, how to move a light through any number of ZIP LEDs.
- And, how to control the speed of movement of an LED around a ring using a potentiometer.
Building This Circuit On The Prototyping System:
It is also possible to build the ZIP LEDs Experiment 10 circuit using the Prototyping System for the BBC micro:bit and the components listed at the top of the page. Once you have sourced the required parts you can follow the diagram below. However, if you have the Inventors Kit and the ZIP LED add-on pack, you will already have all of the parts that you require. As a result, you can get to work immediately.
Create the Following Code:
ZIP LEDs Experiment 10 was created using the Microsoft MakeCode Editor. Microsoft's MakeCode Editor is a drag and drop visual editor that provides a simple introduction to programming. Blocks snap together to build programs and are grouped by the type of function they do. This experiment makes use of the NeoPixel blocks package in the MakeCode editor. Full details of how to add this package to the Editor can be found at the end of this resource.What Will Happen:
The code will light up a single red LED, which will begin to move around the ring. In this case, rotating the potentiometer in either direction will affect the speed of rotation around the ring. An anti-clockwise turn will slow the LED and consequently, a clockwise turn will speed it up.What's Going On:

Start loop:

- In the first block, we set the number of LEDs to 12 and which microbit pin is being used and assign them to a variable called ZIPLEDS.
- The second block is to set the first LED at position 0 to red.
- Our third block then shows this LED, making it visible.
Forever loop:

- First of all, we create a new variable called 'Speed'.
- The value that we are going to store in the variable is generated by a map block.
- The map block takes the analogue voltage input from the potentiometer connected to P1 and converts the analogue voltage to a digital value via the microbits ADC (which has a range of 0 to 1023) to whichever range we specify. You can see the values we chose in the above image.
- We then use the value that is in the 'Speed' variable as a pause value in milliseconds.
- The third block is to rotate the LED by 1 on to the next position. The speed at which the red LED moves from one LED to the next is determined by the 'Pause' value, which is influenced as a result of turning the Potentiometer.
- Finally, the fourth Block is to reshow the LED after it has been shifted to the next position.
Adding The NeoPixel Blocks Package To The MakeCode Editor:
ZIP LEDs experiment 10 makes use of the NeoPixel package. This is not added to the Menu as standard, but it can be added in a few mouse clicks.


©Kitronik Ltd – You may print this page & link to it, but must not copy the page or part thereof without Kitronik's prior written consent.
2 comments
Cullen Lewis
Thank you for your question, there are actually a few reasons. The simple ones are that it makes it a little easier to solder a connector to the ZIP circle as you have a choice of GND and it matches the Adafruit connectors. The more in depth reason is you might want to power the ZIP Circle from a different power source than the microcontroller you are running it from. In which case you would need the data pin and one ground to connect to the microcontroller and the second ground and positive to the separate power supply.
Gernot Abel
Why do you have 2xGnd on the zip ring?
Cheers Gernot