My Cart:

0 item(s) - £0.00
You have no items in your shopping cart.

Using Kitronik ZIP LEDs With The BBC microbit

In this practical guide for Kitronik ZIP LEDs, we cover; what ZIP LEDs are, how they work and how to write code for them, using the Microsoft PXT Editor for the BBC microbit. If the technical details are not your cup of tea you can jump straight to the step by step guide and get coding straight away.

zip-leds-front-angle

Each ZIP stick has five addressable RGB LED’s. The name is a nod to the ZIP postal codes used in the US. Each LED can be controlled independently and all LEDs are connected using the same three wire bus. Each LED can produce a full spectrum of colours independent to all of the other LEDs on the bus. Multiple ZIP LEDs can be connected to produce longer strips. The LEDs used are based on the WS2812B part which is compatible with Adafruit NeoPixel and other WS2812B driver code.

Click here to see the datasheet: https://www.kitronik.co.uk/pdf/WS2812B-LED-datasheet.pdf

Some key features of ZIP LEDs are:

  • Each ZIP LED has a Red, Green and Blue element within the LED, and each of these can achieve 256 levels of brightness. This results in 16,777,216 possible output colours.
  • Integrated intelligent reverse connect protection, so a reverse connection of the power supply does not damage the IC in each of the LEDs.
  • Simple 3 wire connection for all LEDs.
  • LEDS can be placed up to 5m apart without the need for any additional circuitry.

zip-leds-front

How do ‘ZIP’ LEDs work?

The ZIP LEDs are connected using a three wire bus. These connects are V+ (3.5V to 5.3V), Gnd (Vss) and Data. The data is fed into the data in pin on the first LED and then out of the data out pin. This then feeds on to the next LED as shown in the graphic below which is taken from the datasheet.

circuit

The control data is made up of 24bits. These are read into the first LED. When a second set of data is sent the first set is then sent out of the first LED and on to the second. In this way the data cascades from one LED to the next. Data sets are separated by reset codes. This is shown in the graphic below (again taken from the datasheet). D1 to D4 refer to four LEDs connected to each other. as you can see the first LED has three blocks of data passed through it, the second two and last LED just one.

data-cycle

The data structure is as follows:

Each 0 or 1 is sent as 1.25uS high to low cycle. The length of the high and low determines if it is a 0 or a 1 being sent. The times are as follows:

T0H 0 code, high time 0.4us
T0L 0 code, low time 0.85us
T1H 1 code, high time 0.85us
T1L 1 code, low time 0.4us
RET 1 code, low time >50us

 

sequence chart

 

Using ZIP LEDS with a BBC micro:bit:

Our ZIP LEDs use the same LEDs as those used in NeoPixels. This means that the NeoPixel blocks for the PXT block editor can easily be used to control them. The following describes how to control the ZIP LEDs on our Servo:Lite board for the BBC microbit.

5623_additional_servo_lite_board_move_mini_bbc_microbit_top

STEP 1: Attach a microbit to the Servo:Lite board.

STEP 2: Put batteries into the Servo:Lite PCB, and turn it on

STEP 3: Connect it to a computer using a micro-USB cable.

STEP 4: Bring up Javascript Blocks Editor (pxt.microbit.orG).

pxt-editor-menu

STEP 5: In the toolbox towards the left of the screen, select the ‘Advanced’ section. Additional packages should appear below.

STEP 6: Select ‘Add Package’.

add-package

STEP 7: In the search bar type ‘neopixel’, then select the ‘neopixel’ box.

NOTE: This will load a set of blocks compatible with Kitronik’s ZIP LEDs, which makes them really easy to code!

STEP 8: Create a variable and name it ‘PixelArray’.

making-a-variable

A variable is like a container which can store information. This could be a number, a word or a piece of information you want your program to remember.

STEP 9: Create the following code.

on-start

This tells the micro:bit that Pin 0 is connected to 5, colour addressable LEDs.

button-a

When button A is pressed, light up all the pixels red.

button-b

When button B is pressed, clear the variable and show it on the LEDs. This will turn them off.

20170602_145737_resized

STEP 10: The program will automatically run on the simulator. Click on the ‘A’ button on the simulator to see the LED pattern. Click on the ‘B’ button to see the message.

STEP 11: Try changing the code to make a different colour.

number

STEP 12: as well as addressing all the LEDs on the Servo:LIte at once it is possible to set them individually, or as a group. The first pixel always has an address of 0 (see diagram below).

code

STEP 13: Change the code under ‘On button A pressed’ to the following. This will set the first two pixels to red, the middle pixel to white and the last two to blue.

20170602_160606_resized

REMEMBER: To show a change you must use a block with ‘show’ in it.

NOTE: You may need to click on ‘More’ under the ‘neopixel’ toolset to view extra blocks.

STEP 14: Try it out. Press A and watch the lights!

STEP 15: Create the code below.

complete-code

This code shows a colour changing pattern when button A is pressed and stops when button B is pressed.

NOTE: The ‘rotate pixels’ tool shifts each pixel colour onto the next pixel. When it reaches the end of the line, it goes back onto to the first pixel.

STEP 16: Try it out. Press A and watch the light show!

20170602_160844_resized

We have developed several products that feature ZIP LEDs, you can find links to them below:

E-Textiles
← Previous Post Next Post →

2 thoughts on “Using Kitronik ZIP LEDs With The BBC microbit”

  • Kari Santos August 28, 2017 at 4:01 am

    Hi - I am having trouble programming additional LEDs - I have added a string of 16 neopixels, and they light white on reset, but won't change colors like the first 5 - can you show a program that has more LEDs attached.

    Reply
    • Mark Donnison August 30, 2017 at 12:37 pm

      Hi Kari, in your code, there will probably be a line of code in an 'on start' block that defines which micro:bit output pin is being used, how many LEDs there are and what LED format the LEDs are. This will all be in one NeoPixel code block and your values will probably be P0, 5 and RGB (GRB format). For 16 LEDs it should be P0, 16 and RGB (GRB format). I hope this helps.

      Reply
Leave a Reply