Arduino Nano 33 IoT - 74HC595 4-Digit 7-Segment Display

This article shows you how to use an Arduino Nano 33 IoT board to control a four-digit display using a 74HC595 chip. It explains these topics:

This guide uses a 4-digit 7-segment display module that can show numbers with decimals. If you want to display a colon, please check the TM1637 4-digit 7-segment Display Module tutorial.

Arduino Nano 33 IoT 74HC595 4-Digit 7-Segment Display

Hardware Preparation

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×74HC595 4-digit 7-segment Display
1×Breadboard
1×Jumper Wires
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
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 .

Overview of 74HC595 4-digit 7-segment Display

A good module for showing temperature or any decimal number is the 74HC595 4-digit 7-segment display. This module usually has four 7-segment lights, four dot lights, and two 74HC595 drivers for each digit.

Pinout

The 74HC595 module, which displays 4 numbers using 7 segments each, has 5 connection pins.

  • SCLK pin: This is a clock input. Connect it to any digital pin on the Arduino Nano 33 IoT.
  • RCLK pin: This is also a clock input. Connect it to any digital pin on the Arduino Nano 33 IoT.
  • DIO pin: This is for data input and output. Connect it to any digital pin on the Arduino Nano 33 IoT.
  • VCC pin: This supplies power to the module. Connect it to a power source between 3.3V and 5V.
  • GND pin: This is the ground connection.
74HC595 module pinout

Wiring Diagram

The table below explains how the Arduino Nano 33 IoT pins connect to the pins of a 74HC595 4-digit 7-segment display.

Arduino Nano 33 IoT 74HC595 7-segment display
3.3VVCC
D7SCLK
D6RCLK
D5DIO

If you are using other pins, update the pin numbers in the code to match.

The wiring diagram between Arduino Nano and 33 IoT 74HC595 Module

This image is created using Fritzing. Click to enlarge image

Library Installation

To easily program the 74HC595 4-digit 7-segment display, you need to add the DIYables_4Digit7Segment_74HC595 library from DIYables.io. Follow these steps to add the library.

  • Open the Library Manager by clicking the Library Manager icon on the left side of the Arduino IDE.
  • Type DIYables_4Digit7Segment_74HC595 in the search box, then look for the DIYables_4Digit7Segment_74HC595 library by DIYables.io.
  • Finally, click the Install button.
Arduino Nano 33 IoT 74HC595 4-digit 7-segment display library

You can also check out this library on Github.

How To Program For 74HC595 4-digit 7-segment using Arduino Nano 33 IoT

  • Add the library.
#include <DIYables_4Digit7Segment_74HC595.h>
  • Set up the Arduino Nano 33 IoT's pins to connect with the SCLK, RCLK, and DIO pins on the display. For example, you can use pins D7, D6, and D5.
#define SCLK D7 // Pin D7 designated as the SCLK interface on the Arduino Nano 33 IoT #define RCLK D6 // Pin D6 designated as the RCLK interface on the Arduino Nano 33 IoT #define DIO D5 // Pin D5 designated as the DIO interface on the Arduino Nano 33 IoT
  • Make a display using the DIYables_4Digit7Segment_74HC595 type.
DIYables_4Digit7Segment_74HC595 display = DIYables_4Digit7Segment_74HC595(CLK, DIO);
  • Now you can show integer numbers with leading zeros, and it works for negative numbers too:
display.printInt(-13, false); // Displays an integer value; acceptable range is from -999 to 9999
  • You can display numbers with decimals. It allows you to add extra zeros at the start and works with negative numbers.
display.printFloat(-9.2, 1, false);
  • You can also show numbers, decimal points, and characters one by one using basic functions.
// Show temperature 9.3°C display.clear(); // Clear the display content display.setNumber(1, 9); // Write digit 9 at the first position display.setDot(1); // Insert a decimal point after the first digit display.setNumber(2, 3); // Write digit 3 at the second position display.setChar(3, SegChars::DEGREE); // Display the degree symbol at the third position display.setChar(4, SegChars::C); // Display the letter C at the fourth position display.show(); // Update the display with the current settings
  • Since the 74HC595 4-digit 7-segment module uses multiplexing to control its individual segments and LEDs, the Arduino Nano 33 IoT code must call the display.show() function inside the main loop, and it must not use the delay() function there.

You can find more details by checking out the library reference here: https://arduinogetstarted.com/reference/library/diyables-4digit7segment-74hc595-library

Arduino Nano 33 IoT Code - Display Integer

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-74hc595-4-digit-7-segment-display */ #include <DIYables_4Digit7Segment_74HC595.h> // DIYables_4Digit7Segment_74HC595 library #define SCLK 7 // The Arduino Nano 33 IoT pin connected to SCLK #define RCLK 6 // The Arduino Nano 33 IoT pin connected to RCLK #define DIO 5 // The Arduino Nano 33 IoT pin connected to DIO DIYables_4Digit7Segment_74HC595 display(SCLK, RCLK, DIO); void setup() { Serial.begin(9600); display.printInt(-13, false); // you can display a value from -999 to 9999 //display.printInt(-132, false); //display.printInt(9132, false); //display.printInt(132, false); //display.printInt(32, false); //display.printInt(2, false); //display.printInt(2, true); } void loop() { display.loop(); // MUST call the display.loop() function in loop() // DO SOMETHING HERE // NOTE: do NOT use the delay() function in loop because it affects to the multiplexing }

Detailed Instructions

If you are new to the Arduino Nano 33 IoT, be sure to check out our Getting Started with Arduino Nano 33 IoT tutorial. Then, follow these steps:

  • Connect the components to the Arduino Nano 33 IoT board as depicted in the diagram.
  • Use a USB cable to connect the Arduino Nano 33 IoT board to your computer.
  • Launch the Arduino IDE on your computer.
  • Select the Arduino Nano 33 IoT board and choose its corresponding COM port.
  • Copy the code above and open it with the Arduino IDE.
  • Click the Upload button in the Arduino IDE to send the code to your Arduino Nano 33 IoT.
  • Check the numbers on the 7-segment display.

Arduino Nano 33 IoT Code - Display Float

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-74hc595-4-digit-7-segment-display */ #include <DIYables_4Digit7Segment_74HC595.h> // DIYables_4Digit7Segment_74HC595 library #define SCLK 7 // The Arduino Nano 33 IoT pin connected to SCLK #define RCLK 6 // The Arduino Nano 33 IoT pin connected to RCLK #define DIO 5 // The Arduino Nano 33 IoT pin connected to DIO DIYables_4Digit7Segment_74HC595 display(SCLK, RCLK, DIO); void setup() { Serial.begin(9600); display.printFloat(-9.2, 1, false); //display.printFloat(-92.4, 1, false); //display.printFloat(-9.24, 2, false); //display.printFloat(192.4, 1, false); //display.printFloat(19.24, 2, false); //display.printFloat(1.924, 3, false); } void loop() { display.loop(); // MUST call the display.loop() function in loop() // DO SOMETHING HERE // NOTE: do NOT use the delay() function in loop because it affects to the multiplexing }

Arduino Nano 33 IoT Code - Display Temperature

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-74hc595-4-digit-7-segment-display */ #include <DIYables_4Digit7Segment_74HC595.h> // DIYables_4Digit7Segment_74HC595 library #define SCLK 7 // The Arduino Nano 33 IoT pin connected to SCLK #define RCLK 6 // The Arduino Nano 33 IoT pin connected to RCLK #define DIO 5 // The Arduino Nano 33 IoT pin connected to DIO DIYables_4Digit7Segment_74HC595 display(SCLK, RCLK, DIO); void setup() { Serial.begin(9600); // display 9.3°C by controlling digit by digit display.clear(); display.setNumber(1, 9); // set 9 at the 1st digit display.setDot(1); // set . at the 1st digit display.setNumber(2, 3); // set 3 at the 2nd digit display.setChar(3, SegChars::DEGREE); // set ° at the 3rd digit display.setChar(4, SegChars::C); // set C at the 3rd digit display.show(); // show on the display } void loop() { display.loop(); // MUST call the display.loop() function in loop() // DO SOMETHING HERE // NOTE: do NOT use the delay() function in loop because it affects to the multiplexing }

Video Tutorial

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