Using a 4 digit, 7 segment display with Raspberry Pi and Go

I’m building a burglar alam with my son, using a Raspberry Pi Zero as the micro-controller, and using Go as the programming language.

That’s led to me needing a few libraries along the way. Today’s library is, the 4 digit, 7 segment display (e.g. part number 3461BS). It can scroll text and display images.

You can grab the code from

err := rpio.Open()
if err != nil {
  fmt.Printf("error: %v\n", err)
defer rpio.Close()

// Setup the display.
// Row 1 (top row of pins).
pD1 := rpio.Pin(8) // BCM pin, see
pa := rpio.Pin(7)
pf := rpio.Pin(16)
pD2 := rpio.Pin(20)
pD3 := rpio.Pin(26)
pb := rpio.Pin(19)
// // Row 2 (bottom row of pins).
pe := rpio.Pin(13)
pd := rpio.Pin(6)
pdp := rpio.Pin(5)
pc := rpio.Pin(0)
pg := rpio.Pin(11)
pD4 := rpio.Pin(9)

disp := segment.NewFourDigitSevenSegmentDisplay(pD1, pa, pf, pD2, pD3, pb, pe, pd, pdp, pc, pg, pD4)
disp.Start(context.Background(), "hello")

reader := bufio.NewReader(os.Stdin)

for {
  s, _ := reader.ReadString('\n')