Skip to main content
shopping_basket Basket 0
Login

Having Fun With the Pimoroni Scroll pHAT HD

Dave Ives
2

scroll pHAT

Trying out the pixel array on a Raspberry Pi 3B (174-7510) and Pi Zero (181-2039) and running example Python scripts.

The Scroll pHAT HD available at 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.

The pHAT uses the IS31FL3731 LED matrix driver chip that communicates with the Raspberry Pi via the standard 40 pin header.

Scroll phat

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.

Software

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.

Python

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)

sphd.show()

That seemed to make sense even for someone like me, who is not familiar with Python.

Examples

Scroll pHAT array
I was then eager to try out some of the examples provided by Pimoroni starting, of course, with “Hello World”.

#!/usr/bin/env python import time import scrollphathd

print("""
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)
# scrollphathd.rotate(degrees=180)

# 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)
while True:
# Show the buffer
scrollphathd.show()
# Scroll the buffer content
scrollphathd.scroll()
# Wait for 0.1s
time.sleep(0.1)

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.

Pi Zero

Pi Zero and Scroll pHAT array

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.

I currently look after production at AB Open. I have a background in the arts, environmental conservation and IT support. In my spare time I do a bit of DJing and I like making things.

Recommended Articles

Comments

December 7, 2020 08:48

Hi - it's the size of Pi Zero (hence the pHAT) - so about 65mm x 30mm

0 Votes

December 2, 2020 09:01

What's the physical size of the display?

0 Votes
DesignSpark Electrical Logolinkedin