ESP8266 NodeMCU – Simple 7 Segment Display control

In this tutorial, we will learn how to control a 7 Segment Display. If you want to control the letter or number in the display, just have to use this tutorial.

Parts Required

To build the global setup you must have the following parts:

Note: You do not need to have a NodeMCU board nor an ESP8266 to follow this tutorial. I am using this board because it is very famous and also because, I will post future tutorials using wifi communications. In order to use other boards, you just have to change the pin number.

7 Segment Display

Figure 1

Seven segment displays are most used to display decimal numbers (0…9) in electronic displays. These displays use light emitting diodes (LEDs) for every of the 7 segments. Therefore it is possible to display decimal numbers if the the right segments are turned on. The figure 2 shows the pinout of a commun 7 segment display to get a better understanding how it works.

Figure 2

The different segments are connected with the corresponding pins on the edge or backside of the display. The 2 middle pins are the common pins and connected to a common cathode or common anode. This depends of the kind of 7 segment display you have. In most cases you will have a common cathode display so that an LED turns on when the signal to the LED is HIGH and to common is connected to ground. If you have an anode segment display the LED turns on when the signal is LOW.

Note that your display might have a dot point on the right side so that in total you have 10 pins to connect to your microcontroller.

It is very good to have a table, like figure 3, to know what pin to use to display a number.

Figure 3

For example, whenever you want to display the number 7, you must turn on the pins A, B and C. Do the same for the oder numbers and letters.


Figure 4

Follow figure 4 and connect the 7 Segment Display to the NodeMCU pins and GND pin (Black Wire) to commun pin in series with a resistor, 1K ohm for example. Everything will be powered from your PC using micro-usb to usb cable. In this configuration, the LEDs in the display will be powered directly from the GPIO pin with 3.3V. It is low voltage level but it works. Let’s try it.


This example use a simple function, that when called turn os specific LEDs to make a number. We can use a library that already have some code done to make letters and numbers appear, but now we are making it pin by pin. This code just make the numbers 2, 5 and 7, but you can continue making more numbers. Copy the main sketch bellow to your Arduino IDE project and save it. Heve fun!!

Please follow and like us:
Ricardo Carreira

Author: Ricardo Carreira

Portuguese Electrical Engineer interested in Automation, Energy, Power generation, Renewables and 3D printers . With a degree in Electrical and Computer Engineering in the field of Energy and Automation. Currently starting in Master’s degree in Electrical Engineering.

Leave a Reply

Your email address will not be published. Required fields are marked *