micro bit and scroll:bit makecode examples

In this article we look at the scroll:bit, this is an add on from Pimoroni which contains a lot of LEDs, in fact there are 119 in total in a 17 x 7 matrix – its controlled by a IS31FL3731 LED matrix driver chip. This is what the add on looks like plugged into a micro:bit

The board comes already assembled and you can use the makecode editor and import the pxt library into it or you can use a python library and use the mu online editor, we will look at the makecode one in these examples

Click on Extensions and then the + and type in https://github.com/pimoroni/pxt-scrollbit to import the scroll:bit into the makecode editor

Parts List

Description Link
Pimoroni scroll:bit Pimoroni scroll:bit from amazon
micro:bit micro:bit from amazon

Examples

I’ve shown the JavaScript examples here, if you copy this into the https://makecode.microbit.org editor as JavaScript you can easily then see the blocks used.

This is an example of what you will see in the block editor

These are fairly similar, these examples all show how to display text, icons or light various LEDs on the scroll:bit

Example 1

basic.forever(function () {
    scrollbit.scrollText("Hello", 128, 50)
})

 

Example 2

scrollbit.clear()
scrollbit.setIcon(
IconNames.Heart,
6,
1,
128
)
scrollbit.show()

 

Example 3

scrollbit.clear()
for (let index = 0; index <= 16; index++) {
    scrollbit.setPixel(index, 0, 128)
}
scrollbit.show()

 

Example 4

scrollbit.clear()
for (let index = 0; index <= 16; index++) {
    scrollbit.setPixel(index, 0, 128)
    basic.pause(1000)
    scrollbit.show()
}

 

Example 5

scrollbit.clear()
for (let index = 0; index <= 166; index++) {
    scrollbit.setPixel(0, index, 128)
    basic.pause(1000)
    scrollbit.show()
}

 

Example 6

basic.forever(function () {
    scrollbit.clear()
    for (let index = 0; index <= 166; index++) {
        scrollbit.setPixel(Math.randomRange(0, 16), Math.randomRange(0, 6), 128)
        basic.pause(1000)
        scrollbit.show()
    }
})

 

Example 7

basic.forever(function () {
    scrollbit.clear()
    scrollbit.setPixel(Math.randomRange(0, 16), Math.randomRange(0, 6), Math.randomRange(20, 128))
    basic.pause(1000)
    scrollbit.show()
})

 

Example 8

basic.forever(function () {
    scrollbit.clear()
    scrollbit.setIcon(
    IconNames.Heart,
    5,
    0,
    50
    )
    scrollbit.show()
    basic.pause(100)
    scrollbit.setIcon(
    IconNames.Heart,
    5,
    0,
    20
    )
    scrollbit.show()
    basic.pause(100)
})