Having Fun With the Pimoroni Scroll pHAT HDFollow article
Trying out the pixel array on a Raspberry Pi 3Band Pi Zero and running example Python scripts.
The Scroll pHAT HD OKdo, features an array of 119 LEDs that act as pixels on a 17 x 7 screen. The pHAT also provides full PWM brightness control over each LED. This means that you can use the Scroll pHAT HD as a scrolling message display, using Python to generate the output, which can be anything from “Hello World”, to real-time weather or tweets.also available at
The pHAT uses the IS31FL3731 LED matrix driver chip that communicates with the Raspberry Pi via the standard 40 pin header.
The pHAT comes with a female header to attach it to your Raspberry Pi, that requires soldering – so that was my first job. As ever a handy bit of blutack held the header in place and ensured it was straight while I soldered it in place.
As with the Pimoroni Skywriter that I was trying out the other week, there is a handy installer that will install the Scroll pHAT HD Python library for you, including a whole load of examples. Simply type the following in the Terminal:
curl https://get.pimoroni.com/scrollphathd | bash
I also noticed mention of a Pimoroni Dashboard for Raspian, so I thought I would give that a go as I had not encountered it before and the chances are this will not be the last Pimoroni product I set up on my Pi. It is easily installed from the Terminal by simply typing:
sudo apt-get install pimoroni
This adds an item to the Accessories section in the Main Menu. On opening it you can choose to install the necessary software for all sorts of Pimoroni products.
Before trying out the examples provided, I thought I would run through the introductory tutorial so that I would at least have a very basic understanding of the Python scripts.
First of all I needed to open a Python prompt by typing ‘python’ in a Terminal window. Then I followed the instructions to light an individual pixel. The pixels on Scroll pHAT HD are addressed by x/y coordinates, so to light the second pixel in the first row, for example, this pixel would be 0, 1. Remembering that in Python things are numbered from 0, hence the first pixel is 0, the second is 1, and so on.
To avoid typing the rather long-winded scrollphathd each time I wanted to call a function, I could type the following to import the scrollphathd library and then I would just need to type just sphd:
import scrollphathd as sphd
As well as the x/y coordinate of the pixel, I also needed to give it a brightness value. Brightness is a floating point (decimal) number between 0.0 and 1.0. I used the set_pixel function to light the second pixel in the first row at 50% brightness by typing the following:
sphd.set_pixel(0, 1, 0.5)
That seemed to make sense even for someone like me, who is not familiar with Python.
I was then eager to try out some of the examples provided by Pimoroni starting, of course, with “Hello World”.
Scroll pHAT HD: Hello World
Scrolls "Hello World" across the screen
using the default 5x7 pixel large font.
Press Ctrl+C to exit!
# Uncomment the below if your display is upside down
# (e.g. if you're using it in a Pimoroni Scroll Bot)
# Write the "Hello World!" string in the buffer and
# set a more eye-friendly default brightness
scrollphathd.write_string(" Hello World!", brightness=0.5)
# Auto scroll using a while + time mechanism (no thread)
# Show the buffer
# Scroll the buffer content
# Wait for 0.1s
Having gained a bit of an understanding of how Python works, I could easily open the example file and edit it to tweak the output – in this example just changing it to say “DesignSpark” instead of “Hello World”.
As you can see, the examples are clearly annotated and therefore simple tweaks, such as changing the brightness of the pixels or the speed of the scroll, are easy to make.
To run any of the examples open a Terminal and navigate to the folder where they are saved – the default is Pimorono/scrollhathd/examples – and then type:
sudo python hello-world.py
To stop the example running just press Ctrl-C.
As the Scroll pHAT HD was designed for use on a Pi Zero I thought I would give it a try. I simply transferred it to a Zero, taking extra care not to damage any of the GPIO Header pins in the process. To make life easier for myself I swapped out the Raspbian Micro SD card as well, so all the software I needed was ready to go once the Zero booted up. I used the swirl example to try it out.
As long as you are not bothered by a slightly longer boot up time and are not intending on running anything too resource hungry in conjunction with the Scroll pHAT HD, this makes a really neat little package.
More Advanced Examples
I was interested in trying out the Twitter example which will display a Twitter hashtag. To get this working I needed to edit the example script to include my Twitter App Keys. To get these I needed to apply for a developer account on Twitter. I could do that for free as a “hobbyist”, there were just a few online forms to fill in and then a wait while my application is approved.
Unfortunately, at the time of writing, I am still waiting for my developer account, but I am keen to give it a go as I think it would be fun to tweet information about music I am playing when I am DJ’ing and have it displayed for all to see. I was also interested in the Wunderground Weather display example but this also requires an API, this time from Wunderground and that requires me to have a weather station registered with them. Maybe another one for a future project.