Arduino UNO R4 - 74HC595 4-Digit 7-Segment Display

The Arduino Uno R4 - available as Minima and WiFi - brings more processing power, additional memory, and a 14-bit ADC while keeping the classic Uno header layout. The 74HC595 4-digit 7-segment display module connects to the Uno R4 using the same pins as the classic Uno.

In this guide you will:

Arduino Uno R4 74HC595 4-Digit 7-Segment Display

74HC595 4-Digit 7-Segment Display Overview

The 74HC595-based 4-digit 7-segment display module packs four digits, each with 7 LED segments and a decimal point, behind a single shift register. This means you only need 3 pins from your microcontroller to drive the entire display.

The module handles multiplexing internally through the software library. You just call print() with a value and keep calling loop() to refresh.

Function Pin Description
SCLK (SH_CP) Serial Clock Clock signal for shifting data into the register
RCLK (ST_CP) Register Clock Latch to push shifted data to the output pins
DIO (DS) Data Input Serial data fed into the shift register
VCC Power 3.3V or 5V supply
GND Ground Common ground

Wiring Diagram

Wire the display module to the Arduino Uno R4 as follows:

  • SCLK to pin 7
  • RCLK to pin 6
  • DIO to pin 5
  • VCC to 5V
  • GND to GND
The wiring diagram between Arduino Uno R4 74HC595 4-Digit 7-Segment Display

This image is created using Fritzing. Click to enlarge image

See The best way to supply power to the Arduino Uno R4 and other components.

How to Install the Library

  1. Plug the Arduino Uno R4 into your computer using a USB Type-C cable.
  2. In the Arduino IDE, verify that the correct board (Arduino Uno R4 Minima or WiFi) and serial port are selected.
  3. Click the Libraries icon in the left sidebar.
  4. Type "DIYables_4Digit7Segment_74HC595" into the search box and locate the library published by DIYables.
  5. Hit Install to add the library to your IDE. Select version 2.0.0 or later.
Arduino 74HC595 4-Digit 7-Segment Display library

No additional dependencies are needed - the library is entirely self-contained.

Minimal Sketch Structure

All sketches using the DIYables_4Digit7Segment_74HC595 library share this skeleton:

#include <DIYables_4Digit7Segment_74HC595.h> #define SCLK_PIN 7 #define RCLK_PIN 6 #define DIO_PIN 5 DIYables_4Digit7Segment_74HC595 display(SCLK_PIN, RCLK_PIN, DIO_PIN); void setup() { display.begin(); display.print(1234); } void loop() { display.loop(); }

Call display.begin() once in setup() to configure the pins. Then call display.loop() repeatedly so the library can multiplex through the 4 digits. Set the display content with print() - the value persists until you change it.

If you need a delay in your code, use display.delay(ms) so the display keeps refreshing.

Display Integers

This example shows integers on the display, cycling through several values including negative numbers and zero-padded output.

/* * This Arduino UNO R4 code was developed by newbiely.com * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-74hc595-4-digit-7-segment-display */ #include <DIYables_4Digit7Segment_74HC595.h> // Pin configuration - change these to match your wiring #define SCLK_PIN 7 // The Arduino Uno R4 pin connected to the Serial clock pin of 7-segment display #define RCLK_PIN 6 // The Arduino Uno R4 pin connected to the Register clock / latch pin of 7-segment display #define DIO_PIN 5 // The Arduino Uno R4 pin connected to the Data (DS) pin of 7-segment display DIYables_4Digit7Segment_74HC595 display(SCLK_PIN, RCLK_PIN, DIO_PIN); int numbers[] = {0, 42, 1234, -5, -123, 9999}; int numCount = 6; int currentIndex = 0; bool showZeroPad = false; unsigned long lastChange = 0; void setup() { Serial.begin(9600); display.begin(); Serial.println("4-Digit 7-Segment 74HC595 - Integer Example"); } void loop() { display.loop(); // Must be called frequently to refresh the display if (millis() - lastChange >= 2000) { lastChange = millis(); if (!showZeroPad) { display.print(numbers[currentIndex]); Serial.print("Displaying: "); Serial.println(numbers[currentIndex]); currentIndex++; if (currentIndex >= numCount) { currentIndex = 0; showZeroPad = true; } } else { display.print(42, true); // Shows "0042" Serial.println("Displaying: 0042 (zero-padded)"); showZeroPad = false; } } }

How to Run

  • Wire the display to the Uno R4 as described above.
  • Plug in the USB Type-C cable.
  • Paste the code in Arduino IDE, choose the correct board and port, and press Upload.
  • Open the Serial Monitor to see the output.

The display cycles through 0, 42, 1234, -5, -123, and 9999, then shows 0042 (zero-padded). Each value stays for 2 seconds.

Method Quick Reference

Method What It Does Usage
print(int) Show an integer (-999 to 9999) display.print(1234)
print(int, true) Show integer with leading zeros display.print(42, true)
loop() Refresh the display multiplexing display.loop()
begin() Initialize display pins display.begin()

Display Floats

This example demonstrates float display with automatic and manually specified decimal places.

/* * This Arduino UNO R4 code was developed by newbiely.com * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-74hc595-4-digit-7-segment-display */ #include <DIYables_4Digit7Segment_74HC595.h> // Pin configuration - change these to match your wiring #define SCLK_PIN 7 // The Arduino Uno R4 pin connected to the Serial clock pin of 7-segment display #define RCLK_PIN 6 // The Arduino Uno R4 pin connected to the Register clock / latch pin of 7-segment display #define DIO_PIN 5 // The Arduino Uno R4 pin connected to the Data (DS) pin of 7-segment display DIYables_4Digit7Segment_74HC595 display(SCLK_PIN, RCLK_PIN, DIO_PIN); void setup() { Serial.begin(9600); display.begin(); Serial.println("4-Digit 7-Segment 74HC595 - Float Example"); } void loop() { // Auto decimal placement display.print(1.5); // Shows " 1.5" Serial.println("Auto decimal: 1.5"); display.delay(2000); display.print(12.34); // Shows "12.34" Serial.println("Auto decimal: 12.34"); display.delay(2000); display.print(3.141); // Shows "3.141" Serial.println("Auto decimal: 3.141"); display.delay(2000); display.print(-1.2); // Shows "-1.20" Serial.println("Auto decimal: -1.20"); display.delay(2000); display.print(0.5); // Shows " 0.5" Serial.println("Auto decimal: 0.5"); display.delay(2000); // Fixed decimal places display.print(23.5, 1); // 1 decimal place: shows "23.5" Serial.println("1 decimal place: 23.5"); display.delay(2000); display.print(1.5, 2); // 2 decimal places: shows "1.50" Serial.println("2 decimal places: 1.50"); display.delay(2000); // Zero-padded display.print(1.5, 2, true); // Shows "01.50" Serial.println("2 decimal places, zero-padded: 01.50"); display.delay(2000); }

How to Run

  • Paste the code in Arduino IDE, choose the correct board and port, and press Upload.
  • Open the Serial Monitor to see the output.

Floats are displayed with auto decimal places first, then with 1 and 2 fixed decimal places, and finally with zero-padding.

Display Text and Temperature

This example covers text strings, the degree symbol, and the temperature display method.

/* * This Arduino UNO R4 code was developed by newbiely.com * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-74hc595-4-digit-7-segment-display */ #include <DIYables_4Digit7Segment_74HC595.h> // Pin configuration - change these to match your wiring #define SCLK_PIN 7 // The Arduino Uno R4 pin connected to the Serial clock pin of 7-segment display #define RCLK_PIN 6 // The Arduino Uno R4 pin connected to the Register clock / latch pin of 7-segment display #define DIO_PIN 5 // The Arduino Uno R4 pin connected to the Data (DS) pin of 7-segment display DIYables_4Digit7Segment_74HC595 display(SCLK_PIN, RCLK_PIN, DIO_PIN); const char* texts[] = {"HELP", "Hi", "COOL", "done"}; int textCount = 4; int currentIndex = 0; int phase = 0; unsigned long lastChange = 0; void setup() { Serial.begin(9600); display.begin(); Serial.println("4-Digit 7-Segment 74HC595 - Text and Degree Example"); } void loop() { display.loop(); // Must be called frequently to refresh the display if (millis() - lastChange >= 2000) { lastChange = millis(); if (phase == 0) { // Display text strings display.print(texts[currentIndex]); Serial.print("Text: "); Serial.println(texts[currentIndex]); currentIndex++; if (currentIndex >= textCount) { currentIndex = 0; phase = 1; } } else if (phase == 1) { // Display temperature 25 degrees C display.printTemperature(25, 'C'); Serial.println("Temperature: 25 C"); phase = 2; } else if (phase == 2) { // Display temperature 72 degrees F display.printTemperature(72, 'F'); Serial.println("Temperature: 72 F"); phase = 3; } else if (phase == 3) { // Display degree symbol using string with DEGREE_CHAR constant char degStr[5]; degStr[0] = '2'; degStr[1] = '5'; degStr[2] = DEGREE_CHAR; degStr[3] = 'C'; degStr[4] = '\0'; display.print(degStr); Serial.println("String with degree: 25 deg C"); phase = 4; } else { // Display string with dots display.print("1.2.3.4"); Serial.println("Dots: 1.2.3.4"); phase = 0; } } }

How to Run

  • Upload the sketch and open the Serial Monitor.

The display shows text like "HELP" and "COOL", then temperature values with the degree symbol and unit letter.

Display Time

Shows a clock-style HH.MM display with a blinking dot between hours and minutes.

/* * This Arduino UNO R4 code was developed by newbiely.com * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-74hc595-4-digit-7-segment-display */ #include <DIYables_4Digit7Segment_74HC595.h> // Pin configuration - change these to match your wiring #define SCLK_PIN 7 // The Arduino Uno R4 pin connected to the Serial clock pin of 7-segment display #define RCLK_PIN 6 // The Arduino Uno R4 pin connected to the Register clock / latch pin of 7-segment display #define DIO_PIN 5 // The Arduino Uno R4 pin connected to the Data (DS) pin of 7-segment display DIYables_4Digit7Segment_74HC595 display(SCLK_PIN, RCLK_PIN, DIO_PIN); int hours = 12; int minutes = 30; bool colonOn = true; unsigned long lastToggle = 0; void setup() { Serial.begin(9600); display.begin(); Serial.println("4-Digit 7-Segment 74HC595 - Time Example"); Serial.println("Displaying 12:30 with blinking dot separator"); } void loop() { display.loop(); // Must be called frequently to refresh the display if (millis() - lastToggle >= 500) { lastToggle = millis(); display.printTime(hours, minutes, colonOn); colonOn = !colonOn; // Toggle dot separator every 500ms for blinking effect } }

How to Run

  • Upload the sketch and open the Serial Monitor.

The display reads 12.30 with the dot toggling every 500ms to create a blinking separator.

Troubleshooting

  • Nothing on the display - Double-check VCC and GND connections. Confirm SCLK, RCLK, and DIO pins match the code. Make sure begin() is in setup() and loop() calls display.loop().
  • Wrong or garbled characters - Verify common anode vs common cathode. Default is common anode. For common cathode, pass false: DIYables_4Digit7Segment_74HC595 display(7, 6, 5, false).
  • Display goes blank or flickers - Avoid delay() in your code. Use display.delay() instead to keep the multiplexing active.

Platform Support

The library relies exclusively on Arduino standard APIs (pinMode, digitalWrite, millis) and runs on all Arduino-compatible platforms.

※ 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!