Arduino - 74HC595 4-Digit 7-Segment Display
This tutorial instructs you how to use a 4-digit 7-segment display module with a 74HC595 shift register using Arduino. In detail, we will learn:
- How to wire the 74HC595 4-digit 7-segment display module to an Arduino.
- How to display integers and floats on the display.
- How to display text and special characters like the degree symbol.
- How to show time and temperature readings.

Hardware Required
Or you can buy the following kits:
| 1 | × | DIYables STEM V3 Starter Kit (Arduino included) | |
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some links direct to products from our own brand, DIYables .
About 4-Digit 7-Segment Display with 74HC595
The 4-digit 7-segment display module with 74HC595 is a compact display that uses a shift register to reduce the number of pins needed from the microcontroller. Instead of requiring 12+ pins, this module only uses 3 data pins (SCLK, RCLK, DIO) to control all 4 digits and their decimal points.
Each digit consists of 7 LED segments (labeled A through G) plus a decimal point (DP). By turning on different combinations of segments, the display can show digits 0-9, several letters, and special characters.
The module supports both common anode and common cathode configurations. This tutorial uses the common anode version.
Pin Mapping
| Function | Pin | Description |
|---|---|---|
| SCLK (SH_CP) | Serial Clock | Clock signal for shifting data |
| RCLK (ST_CP) | Register Clock | Latch signal to output shifted data |
| DIO (DS) | Data Input | Serial data input |
| VCC | Power | 3.3V or 5V |
| GND | Ground | Ground connection |
Wiring Diagram
Connect the 74HC595 display module to Arduino as follows:
- SCLK to Arduino pin 7
- RCLK to Arduino pin 6
- DIO to Arduino pin 5
- VCC to 5V
- GND to GND

This image is created using Fritzing. Click to enlarge image
Library Installation
- Connect the Arduino board to your computer with a USB cable.
- Open Arduino IDE, select the right board and port.
- Navigate to the Libraries icon on the left bar of the Arduino IDE.
- Search "DIYables_4Digit7Segment_74HC595", then find the DIYables_4Digit7Segment_74HC595 library by DIYables.
- Click Install button to install the library. Select version 2.0.0 or later.

Note: This library is self-contained with no external dependencies.
Basic Structure
Every sketch using the DIYables_4Digit7Segment_74HC595 library follows this basic structure:
The display uses multiplexing to show all 4 digits. The display.loop() method handles the refresh cycle and must be called frequently in your loop() function. You set the content once with print(), and it stays on the display as long as loop() keeps running.
If your code has long delays, use display.delay(ms) instead of the standard delay(ms) to keep the display refreshed during the wait.
Arduino Code - Display Integers
This example shows how to display integer numbers on the 7-segment display, including negative numbers and zero-padding.
Quick Steps
- Wire the display module to Arduino as shown in the wiring diagram above.
- Connect the Arduino board to your computer with a USB cable.
- Open Arduino IDE, select the right board and port.
- Copy the above code and paste it to the editor of Arduino IDE.
- Click Upload button on Arduino IDE to upload code to Arduino.
- Open the Serial Monitor to see the output.
The display cycles through several integers: 0, 42, 1234, -5, -123, 9999, and then shows 42 with zero-padding (0042). Each value is displayed for 2 seconds.
API Summary
| Method | Description | Example |
|---|---|---|
| print(int) | Display an integer (-999 to 9999) | display.print(1234) |
| print(int, true) | Display integer with leading zeros | display.print(42, true) shows 0042 |
| loop() | Refresh the display (call in loop) | display.loop() |
Arduino Code - Display Floats
This example demonstrates displaying floating-point numbers with automatic and manual decimal places.
Quick Steps
- Wire the display module to Arduino as shown above.
- Copy the above code and paste it to the editor of Arduino IDE.
- Click Upload button on Arduino IDE to upload code to Arduino.
- Open the Serial Monitor.
The display shows various float values. With auto decimal places, the library picks the best fit. You can also set a fixed number of decimal places and enable zero-padding.
API Summary
| Method | Description | Example |
|---|---|---|
| print(double) | Display float with auto decimals | display.print(12.34) |
| print(double, dp) | Display float with dp decimal places | display.print(1.5, 2) shows 1.50 |
| print(double, dp, true) | Float with decimals and zero-pad | display.print(1.5, 2, true) |
Arduino Code - Display Text and Temperature
This example shows how to display text strings, the degree symbol, and temperature values.
Quick Steps
- Wire the display module to Arduino as shown above.
- Copy the above code and paste it to the editor of Arduino IDE.
- Click Upload button on Arduino IDE to upload code to Arduino.
- Open the Serial Monitor.
The display shows text like "HELP", "Hi", "COOL", and "done", then temperature values 25 degrees C and 72 degrees F, then a string with the degree constant, and finally dots on every digit (1.2.3.4).
API Summary
| Method | Description | Example |
|---|---|---|
| print(const char*) | Display a text string (up to 4 chars) | display.print("HELP") |
| printTemperature(int, char) | Show temperature with degree and unit | display.printTemperature(25, 'C') |
| DEGREE_CHAR | Constant for the degree symbol | display.print("25" + degStr) |
Arduino Code - Display Time
This example displays a clock-style time in HH.MM format with a blinking dot separator.
Quick Steps
- Wire the display module to Arduino as shown above.
- Copy the above code and paste it to the editor of Arduino IDE.
- Click Upload button on Arduino IDE to upload code to Arduino.
- Open the Serial Monitor.
The display shows 12.30 with the dot between the second and third digit blinking every 500ms, creating a clock-like appearance.
Arduino Code - Blink Display
This example blinks different values on and off using the off() and on() methods.
Quick Steps
- Wire the display module to Arduino as shown above.
- Copy the above code and paste it to the editor of Arduino IDE.
- Click Upload button on Arduino IDE to upload code to Arduino.
- Open the Serial Monitor.
The display blinks the integer 1234, then the float 12.34, then the text "HELP" - each blinking 5 times before moving to the next.
API Summary
| Method | Description | Example |
|---|---|---|
| off() | Turn off the display | display.off() |
| on() | Turn the display back on | display.on() |
| delay(ms) | Display-aware delay (keeps refreshing) | display.delay(1000) |
| yield() | Single refresh call for long loops | display.yield() |
Troubleshoot
If the code is not working, there are some common issues you can troubleshoot:
- Display shows nothing: Check that VCC and GND are connected. Verify the SCLK, RCLK, and DIO pins match your code. Make sure display.begin() is called in setup() and display.loop() is called in loop().
- Segments show wrong characters: Confirm whether your module is common anode or common cathode. The default is common anode. For common cathode, pass false as the fourth parameter: DIYables_4Digit7Segment_74HC595 display(7, 6, 5, false).
- Display flickers or goes blank: The display.loop() must be called frequently. Avoid using delay() in your code - use display.delay() instead to keep the display refreshed.
Platform Support
The library uses only Arduino standard APIs (pinMode, digitalWrite, millis) and supports all Arduino platforms (architectures=*).