Raspberry Pi Pico - 74HC595 4-Digit 7-Segment Display

The Raspberry Pi Pico is a low-cost, high-performance microcontroller board built on the RP2040 chip. Paired with MicroPython and the DIYables 4-Digit 7-Segment Display module (74HC595), you can easily show numbers, text, and sensor readings on a bright LED display.

This tutorial walks you through:

Raspberry Pi Pico 4-Digit 7-Segment Display 74HC595

Components Needed

1×Raspberry Pi Pico W
1×Raspberry Pi Pico Alternatively,
1×Micro USB Cable
1×74HC595 4-digit 7-segment Display
1×Breadboard
1×Jumper Wires
1×Recommended: Screw Terminal Expansion Board for Raspberry Pi Pico

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

The 4-Digit 7-Segment Display 74HC595 Module

The DIYables 4-Digit 7-Segment Display 74HC595 module is a compact LED display driven by two 74HC595 shift registers. It shows 4 digits and 4 decimal point dots. Because the shift registers handle all the segment and digit driving, the Raspberry Pi Pico only needs 3 GPIO pins (clock, latch, and data) instead of the 12+ pins a raw display would require.

The Pico communicates with the module by shifting out segment data and digit-select data serially. The library handles this automatically using a hardware Timer for multiplexing — each digit is refreshed in turn at high speed, so all 4 digits appear lit simultaneously.

Key features of the module:

  • Only 3 wires for data (SCLK, RCLK, DIO) plus power.
  • 4 decimal point dots — individually controllable.
  • Common anode or common cathode variants available.
  • 5V or 3.3V compatible.

Pin Description

Pin Purpose Raspberry Pi Pico Connection
SCLK (SH_CP) Serial clock input Connect to GP2
RCLK (ST_CP) Register clock / latch Connect to GP1
DIO (DS) Serial data input Connect to GP0
VCC 3.3V to 5V power input Connect to 3V3(OUT)
GND Ground Connect to GND
4-Digit 7-Segment Display 74HC595 Pinout

Wiring

The Raspberry Pi Pico operates at 3.3V logic natively. The 74HC595 module works with both 3.3V and 5V, so you wire directly — no level shifting needed.

74HC595 Module Raspberry Pi Pico Notes
SCLK (SH_CP) GP2 Serial clock
RCLK (ST_CP) GP1 Latch / register clock
DIO (DS) GP0 Serial data
VCC 3V3(OUT) Power (3.3V output pin)
GND GND Ground
The wiring diagram between Raspberry Pi and Pico 4-Digit 7-Segment Display 74HC595

This image is created using Fritzing. Click to enlarge image

Tip: You can use any available GPIO pins on the Pico. Just update the pin numbers in the code.

Detailed Instructions

Here's instructions on how to set up and run your MicroPython code on the Raspberry Pi Pico using Thonny IDE:

  • Make sure Thonny IDE is installed on your computer.
  • Confirm that MicroPython firmware is loaded on your Raspberry Pi Pico board.
  • If this is your first time using a Raspberry Pi Pico with MicroPython, check out the Raspberry Pi Pico MicroPython Getting Started guide for step-by-step instructions.
  • Connect the Raspberry Pi Pico board to the 4-digit 7-segment display module according to the provided diagram.
  • Connect the Raspberry Pi Pico board to your computer with a USB cable.
  • Open Thonny IDE on your computer.
  • In Thonny IDE, go to Tools Options.
  • Under the Interpreter tab, choose MicroPython (Raspberry Pi Pico) from the dropdown menu.
  • Make sure the correct port is selected. Thonny IDE usually detects it automatically, but you might need to select it manually (like COM12 on Windows or /dev/ttyACM0 on Linux).
  • Navigate to the Tools Manage packages on the Thonny IDE.
  • Search "DIYables-MicroPython-4Digit7Segment-74HC595", then find the 4-Digit 7-Segment Display library created by DIYables.
  • Click on DIYables-MicroPython-4Digit7Segment-74HC595, then click Install button to install the library.
Raspberry Pi Pico 4-Digit 7-Segment Display 74HC595 library
  • Copy the provided MicroPython code and paste it into Thonny's editor.
  • Save the code to your Raspberry Pi Pico by:
    • Clicking the Save button or pressing Ctrl+S.
    • In the save dialog, choose MicroPython device.
    • Name the file main.py.
  • Click the green Run button (or press F5) to execute the script.
  • Observe the display — you should see numbers, text, or other content appear on the 7-segment display.

Starter Code Template

from DIYables_MicroPython_4Digit7Segment_74HC595 import Display4Digit7Segment74HC595 import time display = Display4Digit7Segment74HC595(sclk_pin=2, rclk_pin=1, dio_pin=0, common_anode=True) #The display auto-refreshes in the background using a hardware Timer. #Just call display.print() and the display stays on automatically. display.print(1234)

Raspberry Pi Pico Code — Display Integers

""" Example: Display integer numbers on 4-digit 7-segment display with 74HC595. Works with: ESP32, Raspberry Pi Pico, Arduino Nano ESP32, Arduino Nano R1 WiFi Wiring guide: Raspberry Pi Pico: 74HC595 Module Raspberry Pi Pico ────────────── ───────────────── SCLK (SH_CP) -> GP2 RCLK (ST_CP) -> GP1 DIO (DS) -> GP0 VCC -> 3.3V (pin 36) GND -> GND (pin 38) """ from DIYables_MicroPython_4Digit7Segment_74HC595 import Display4Digit7Segment74HC595 import time SCLK_PIN = 2 RCLK_PIN = 1 DIO_PIN = 0 display = Display4Digit7Segment74HC595(SCLK_PIN, RCLK_PIN, DIO_PIN, common_anode=True) while True: # Display integers numbers = [0, 42, 1234, -5, -123, 9999] for num in numbers: display.print(num) time.sleep(2) # Display with zero padding display.print(42, zero_pad=True) # Shows "0042" time.sleep(2)

Try It

  • Wire the module, connect the Pico via USB.
  • Upload the code using Thonny IDE.
  • The display cycles through several integers (0, 42, 1234, -5, -123, 9999) and a zero-padded number (0042).

Integer Display

The print() method auto-detects integers and formats them right-aligned on the display.

Method Call Display Shows Notes
display.print(0) " 0" Single digit, right-aligned
display.print(42) " 42" Two digits
display.print(1234) "1234" All four digits
display.print(-5) " -5" Negative with minus sign
display.print(-123) "-123" Negative, full width
display.print(9999) "9999" Maximum positive value
display.print(42, zero_pad=True) "0042" Leading zeros

Integer range: -999 to 9999. Values outside this range display "Err".

Raspberry Pi Pico Code — Display Floats

""" Example: Display float numbers on 4-digit 7-segment display with 74HC595. Works with: ESP32, Raspberry Pi Pico, Arduino Nano ESP32, Arduino Nano R1 WiFi Wiring guide: Raspberry Pi Pico: 74HC595 Module Raspberry Pi Pico ────────────── ───────────────── SCLK (SH_CP) -> GP2 RCLK (ST_CP) -> GP1 DIO (DS) -> GP0 VCC -> 3.3V (pin 36) GND -> GND (pin 38) """ from DIYables_MicroPython_4Digit7Segment_74HC595 import Display4Digit7Segment74HC595 import time SCLK_PIN = 2 RCLK_PIN = 1 DIO_PIN = 0 display = Display4Digit7Segment74HC595(SCLK_PIN, RCLK_PIN, DIO_PIN, common_anode=True) while True: # Display floats with auto decimal places floats = [1.5, 12.34, 3.141, -1.2, 0.5] for num in floats: display.print(num) time.sleep(2) # Display with specific decimal places display.print(23.5, decimal_places=1) # Shows "23.5" time.sleep(2) # Display 1.5 with auto decimal places display.print(1.5) # Shows "1.5" time.sleep(2) # Display 1.5 with 2 decimal places display.print(1.5, decimal_places=2) # Shows "1.50" time.sleep(2) # Display 1.5 with 2 decimal places and zero padding display.print(1.5, decimal_places=2, zero_pad=True) # Shows "01.50" time.sleep(2)

Float Display

The decimal point dot is automatically placed at the correct position. You can let the library choose the number of decimal places, or specify it manually.

Method Call Display Shows Notes
display.print(1.5) " 1.5" Auto decimal places
display.print(12.34) "12.34" Auto — 2 decimal places
display.print(3.141) "3.141" Auto — 3 decimal places
display.print(23.5, decimal_places=1) "23.5" Forced 1 decimal place
display.print(1.5, decimal_places=2) " 1.50" Forced 2 decimal places with trailing zero
display.print(1.5, decimal_places=2, zero_pad=True) "01.50" Zero-padded with 2 decimal places

Raspberry Pi Pico Code — Display Text, Degree, and Temperature

""" Example: Display text, special characters, and temperature on 4-digit 7-segment display. Works with: ESP32, Raspberry Pi Pico, Arduino Nano ESP32, Arduino Nano R1 WiFi Wiring guide: Raspberry Pi Pico: 74HC595 Module Raspberry Pi Pico ────────────── ───────────────── SCLK (SH_CP) -> GP2 RCLK (ST_CP) -> GP1 DIO (DS) -> GP0 VCC -> 3.3V (pin 36) GND -> GND (pin 38) """ from DIYables_MicroPython_4Digit7Segment_74HC595 import Display4Digit7Segment74HC595 import time SCLK_PIN = 2 RCLK_PIN = 1 DIO_PIN = 0 display = Display4Digit7Segment74HC595(SCLK_PIN, RCLK_PIN, DIO_PIN, common_anode=True) while True: # Display text strings texts = ["HELP", "Hi", "COOL", "done"] for text in texts: display.print(text) time.sleep(2) # Display temperature with degree symbol display.print_temperature(25, 'C') # Shows "25°C" time.sleep(2) display.print_temperature(72, 'F') # Shows "72°F" time.sleep(2) # Display string with degree constant display.print("25" + display.DEGREE + "C") # Same as print_temperature(25, 'C') time.sleep(2) # Display string with dots display.print("1.2.3.4") # Shows "1.2.3.4" with dots on digits 0,1,2 time.sleep(2)

Supported Characters

The display can show a subset of alphabetic characters that are legible on a 7-segment display:

  • Digits: 0-9
  • Letters: A, b, C, c, d, E, F, G, H, h, I, i, J, L, n, O, o, P, r, S, t, U, u, Y
  • Special: ° (degree), - (dash), _ (underscore), (space)

Temperature Display

Method Call Display Shows Notes
display.print_temperature(25, 'C') "25°C" Celsius
display.print_temperature(72, 'F') "72°F" Fahrenheit
display.print_temperature(-5, 'C') "-5°C" Negative temperature
display.print_temperature(100, 'C') "100°" No room for unit

You can also build temperature strings manually using the DEGREE constant:

display.print("25" + display.DEGREE + "C") # Same as print_temperature(25, 'C')

Dot Handling in Strings

A . character in a string activates the decimal point dot on the preceding digit rather than occupying its own position:

display.print("1.2.3.4") # Shows digits 1, 2, 3, 4 with dots on digits 0, 1, 2

Raspberry Pi Pico Code — Display Time

""" Example: Display time with blinking dot separator on 4-digit 7-segment display. Note: This module has dots only (no colon). The dot on digit 1 is used as a time separator. Works with: ESP32, Raspberry Pi Pico, Arduino Nano ESP32, Arduino Nano R1 WiFi Wiring guide: Raspberry Pi Pico: 74HC595 Module Raspberry Pi Pico ────────────── ───────────────── SCLK (SH_CP) -> GP2 RCLK (ST_CP) -> GP1 DIO (DS) -> GP0 VCC -> 3.3V (pin 36) GND -> GND (pin 38) """ from DIYables_MicroPython_4Digit7Segment_74HC595 import Display4Digit7Segment74HC595 import time SCLK_PIN = 2 RCLK_PIN = 1 DIO_PIN = 0 display = Display4Digit7Segment74HC595(SCLK_PIN, RCLK_PIN, DIO_PIN, common_anode=True) hours = 12 minutes = 30 colon_on = True while True: display.print_time(hours, minutes, colon=colon_on) time.sleep(0.5) # Toggle dot separator every 500ms for blinking effect colon_on = not colon_on

Time Display

This module has dots only (no colon). The print_time() method uses the dot on digit 1 (second from left) as a time separator.

Method Call Display Shows Notes
display.print_time(12, 30) "12.30" Dot separator on
display.print_time(9, 5) "09.05" Auto zero-padding
display.print_time(12, 30, colon=False) "12 30" Dot separator off

Blinking effect: Toggle the colon parameter every 500ms in your main loop to create a blinking time separator.

API Summary

For the full API reference with detailed parameters and examples, see the Library Reference.

Method Description
print(value, decimal_places, zero_pad) Display int, float, or string (auto-detects type)
print_temperature(temperature, unit) Display temperature with ° symbol
print_time(hours, minutes, colon) Display time HH.MM with dot separator
clear() Clear the display buffer
off() Stop auto-refresh and blank the display
on() Restart auto-refresh
set_char(position, char) Set character at position (0-3)
set_number(position, number) Set digit 0-9 at position (0-3)
set_dot(position, state) Set decimal point at position (0-3)
set_segments(position, segments) Set raw segment bits at position (0-3)

Next Steps

  • Explore the Library Reference for the full API including low-level segment control.
  • Combine the display with sensors (e.g., DHT11, DS18B20) to build a temperature monitor.
  • Use print_time() with the Pico's RTC or NTP to build a simple clock.
  • Add buttons to create a countdown timer or stopwatch.

Learn More

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!