seven segment display

Seven Segment Display With ESP8266 Nodemcu | esp8266 tutorial

ESP8266 / NodeMCU IoT Tutorial

Introduction

Hello geeks, hope you are doing fine. Have you ever seen a seven-segment display? Well if you want to learn the working of a seven-segment display and to display the numbers on it then read the full article carefully. In this article, we are using a nodemcu development board to operate the seven-segment display. These kinds of displays are used in table clocks, calculators, and some other small appliances. This display is named seven segments as it has seven different segments which glow in combinations to display a specific number in this esp8266 tutorial. You can also read more interesting mini projects and final year projects on this website. The code and the circuit diagram both are given below. The only limitation of this display is that it can only display the numbers between zero to nine and for displaying more digits we required more such modules. Also, the brightness is not much sufficient. Check the interfacing of a seven-segment display module with an Arduino board.

Working of the Project

Once the nodemcu starts functioning the display module also starts displaying numbers. You are going to see the zero first then after a time delay of a few seconds other numbers also start displaying in continuation. At last, the small dot is going to be displayed. You can change the order of numbers and the time delay by modifying the given code in the esp8266 tutorial. You have to arrange the components that are given below. There are small LEDs present under each segment of the seven-segment display. Also, check the electronic dice using Arduino made by us. For making a number-like pattern we have to turn on only a few LEDs that are required and keep the remaining LEDs turned off. You can clearly see in the code that we are giving HIGH and LOW commands to the display module in order to display a specific number. Make the connections according to the given diagram.

Components Required

  • ESP8266 nodemcu
  • Seven segment display module ( Common Cathode )
  • Seven segment display module ( Common Anode )
  • 220-ohm resistor
  • Jumper wires and a breadboard
  • USB cable for uploading the code

Components Table/buy table

S.NoComponent NameQuantityBuy Link
1.Nodemcu esp82661https://amzn.to/3EUGhuu
2.Nodemcu cable1https://amzn.to/3F1ywmu
3.Seven Segment Display

 Common Cathode

1https://amzn.to/3umWUdg
4.Seven Segment Display

 Common Anode

1https://amzn.to/3ukF5vg
5.Breadboard1https://amzn.to/39vsRX2
6.Jumper wire40https://amzn.to/39q43jr
7.220-ohm Resistor2https://amzn.to/3oioZkQ


Circuit Diagram of Common Cathode  Project

 

Circuit Diagram of Common Anode  Project

Connection Table

Common Cathode Seven Segment

Nodemcu esp8266Seven Segment Display220 Ohm 2 Resistor 
D2 PinA   Pin 
D3 PinB   Pin 
D6 PinC   Pin 
D5 PinD   Pin 
D4 PinE   Pin 
D1 PinF   Pin 
D0 PinG   Pin 
D7 PinDP Pin 
 Both CommonTerminal 1
G, GND Terminal 2

Common Anode Seven Segment

Nodemcu esp8266Seven Segment Display220 Ohm 2 Resistor 
D2 PinA   Pin 
D3 PinB   Pin 
D6 PinC   Pin 
D5 PinD   Pin 
D4 PinE   Pin 
D1 PinF   Pin 
D0 PinG   Pin 
D7 PinDP Pin 
 Both CommonTerminal 1
Vin, VV Terminal 2

For identifying the correct pins you can use the dot that is given on the bottom side of the display module. This is a common cathode seven-segment display. Connect the GND wire of the nodemcu with the GND pins of the seven-segment display via a 220-ohm resistor. Attach the other pins of the seven-segment display with the digital pins of the esp8266 tutorial as shown above in the circuit diagram. Please make sure that all the connections are tight and perfect. Connect a USB cable to power the nodemcu board and the display starts working.

Code for the Project

NOTE: Please upload this code to the nodemcu.

// Common Cathode Seven Segment
 // TECHATRONIC.COM   
  void setup()   
  {   
  pinMode(16, OUTPUT); // D0 PIN NODEMCU  
  pinMode(5, OUTPUT);  // D1 PIN NODEMCU  
  pinMode(4, OUTPUT);  // D2 PIN NODEMCU  
  pinMode(0, OUTPUT);  // D3 PIN NODEMCU  
  pinMode(2, OUTPUT);  // D4 PIN NODEMCU  
  pinMode(14, OUTPUT); // D5 PIN NODEMCU  
  pinMode(12, OUTPUT); // D6 PIN NODEMCU  
  pinMode(13, OUTPUT); // D7 PIN NODEMCU  
  }   
  void loop()   
  {   
  // ZERO   
  digitalWrite(16, LOW);   
  digitalWrite(5, HIGH);   
  digitalWrite(4, HIGH);   
  digitalWrite(0, HIGH);   
  digitalWrite(2, HIGH);   
  digitalWrite(14, HIGH);   
  digitalWrite(12, HIGH);   
  digitalWrite(13, LOW);   
  delay(2000); // Wait for 2000 millisecond(s)   
  // ONE 1   
  digitalWrite(16, LOW);   
  digitalWrite(5, HIGH);   
  digitalWrite(4, LOW);   
  digitalWrite(0, LOW);   
  digitalWrite(2, HIGH);   
  digitalWrite(14, LOW);   
  digitalWrite(12, LOW);   
  digitalWrite(13, LOW);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // 2 TWO    
  digitalWrite(16, LOW);   
  digitalWrite(5, LOW);   
  digitalWrite(4, HIGH);   
  digitalWrite(0, HIGH);   
  digitalWrite(2, HIGH);   
  digitalWrite(14, HIGH);   
  digitalWrite(12, LOW);   
  digitalWrite(13, HIGH);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // 3 THREE    
  digitalWrite(16, LOW);   
  digitalWrite(5, HIGH);   
  digitalWrite(4, HIGH);   
  digitalWrite(0, LOW);   
  digitalWrite(2, HIGH);   
  digitalWrite(14, HIGH);   
  digitalWrite(12, LOW);   
  digitalWrite(13, HIGH);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // 4 FOUR   
  digitalWrite(15, LOW);   
  digitalWrite(5, HIGH);   
  digitalWrite(4, LOW);   
  digitalWrite(0, LOW);   
  digitalWrite(2, HIGH);   
  digitalWrite(14, LOW);   
  digitalWrite(12, HIGH);   
  digitalWrite(13, HIGH);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // 5 FIVE   
  digitalWrite(16, LOW);   
  digitalWrite(5, HIGH);   
  digitalWrite(4, HIGH);   
  digitalWrite(0, LOW);   
  digitalWrite(2, LOW);   
  digitalWrite(14, HIGH);   
  digitalWrite(12, HIGH);   
  digitalWrite(13, HIGH);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // 6 SIX   
  digitalWrite(16, LOW);   
  digitalWrite(5, HIGH);   
  digitalWrite(4, HIGH);   
  digitalWrite(0, HIGH);   
  digitalWrite(2, LOW);   
  digitalWrite(14, HIGH);   
  digitalWrite(12, HIGH);   
  digitalWrite(13, HIGH);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // 7 SEVEN   
  digitalWrite(16, LOW);   
  digitalWrite(5, HIGH);   
  digitalWrite(4, LOW);   
  digitalWrite(0, LOW);   
  digitalWrite(2, HIGH);   
  digitalWrite(14, HIGH);   
  digitalWrite(12, LOW);   
  digitalWrite(13, LOW);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // 8 EIGHT   
  digitalWrite(16, LOW);   
  digitalWrite(5, HIGH);   
  digitalWrite(4, HIGH);   
  digitalWrite(0, HIGH);   
  digitalWrite(2, HIGH);   
  digitalWrite(14, HIGH);   
  digitalWrite(12, HIGH);   
  digitalWrite(13, HIGH);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // 9 NINE   
  digitalWrite(16, LOW);   
  digitalWrite(5, HIGH);   
  digitalWrite(4, HIGH);   
  digitalWrite(0, LOW);   
  digitalWrite(2, HIGH);   
  digitalWrite(14, HIGH);   
  digitalWrite(12, HIGH);   
  digitalWrite(13, HIGH);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // . DOT   
  digitalWrite(16, HIGH);   
  digitalWrite(5, LOW);   
  digitalWrite(4, LOW);   
  digitalWrite(0, LOW);   
  digitalWrite(2, LOW);   
  digitalWrite(14, LOW);   
  digitalWrite(12, LOW);   
  digitalWrite(13, LOW);   
  delay(2000); // Wait for 2000 millisecond(s)   
  } 


// Common Anode Seven Segment

 // TECHATRONIC.COM   
  void setup()   
  {   
  pinMode(16, OUTPUT); // D0 PIN NODEMCU  
  pinMode(5, OUTPUT);  // D1 PIN NODEMCU  
  pinMode(4, OUTPUT);  // D2 PIN NODEMCU  
  pinMode(0, OUTPUT);  // D3 PIN NODEMCU  
  pinMode(2, OUTPUT);  // D4 PIN NODEMCU  
  pinMode(14, OUTPUT); // D5 PIN NODEMCU  
  pinMode(12, OUTPUT); // D6 PIN NODEMCU  
  pinMode(13, OUTPUT); // D7 PIN NODEMCU  
  }   
  void loop()   
  {   
  // ZERO   
  digitalWrite(16, HIGH);   
  digitalWrite(5, LOW);   
  digitalWrite(4, LOW);   
  digitalWrite(0, LOW);   
  digitalWrite(2, LOW);   
  digitalWrite(14, LOW);   
  digitalWrite(12, LOW);   
  digitalWrite(13, HIGH);   
  delay(2000); // Wait for 2000 millisecond(s)   
  // ONE 1   
  digitalWrite(16, HIGH);   
  digitalWrite(5, LOW);   
  digitalWrite(4, HIGH);   
  digitalWrite(0, HIGH);   
  digitalWrite(2, LOW);   
  digitalWrite(14, HIGH);   
  digitalWrite(12, HIGH);   
  digitalWrite(13, HIGH);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // 2 TWO    
  digitalWrite(16, HIGH);   
  digitalWrite(5, HIGH);   
  digitalWrite(4, LOW);   
  digitalWrite(0, LOW);   
  digitalWrite(2, LOW);   
  digitalWrite(14, LOW);   
  digitalWrite(12, HIGH);   
  digitalWrite(13, LOW);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // 3 THREE    
  digitalWrite(16, HIGH);   
  digitalWrite(5, LOW);   
  digitalWrite(4, LOW);   
  digitalWrite(0, HIGH);   
  digitalWrite(2, LOW);   
  digitalWrite(14, LOW);   
  digitalWrite(12, HIGH);   
  digitalWrite(13, LOW);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // 4 FOUR   
  digitalWrite(15, HIGH);   
  digitalWrite(5, LOW);   
  digitalWrite(4, HIGH);   
  digitalWrite(0, HIGH);   
  digitalWrite(2, LOW);   
  digitalWrite(14, HIGH);   
  digitalWrite(12, LOW);   
  digitalWrite(13, LOW);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // 5 FIVE   
  digitalWrite(16, HIGH);   
  digitalWrite(5, LOW);   
  digitalWrite(4, LOW);   
  digitalWrite(0, HIGH);   
  digitalWrite(2, HIGH);   
  digitalWrite(14, LOW);   
  digitalWrite(12, LOW);   
  digitalWrite(13, LOW);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // 6 SIX   
  digitalWrite(16, HIGH);   
  digitalWrite(5, LOW);   
  digitalWrite(4, LOW);   
  digitalWrite(0, LOW);   
  digitalWrite(2, HIGH);   
  digitalWrite(14, LOW);   
  digitalWrite(12, LOW);   
  digitalWrite(13, LOW);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // 7 SEVEN   
  digitalWrite(16, HIGH);   
  digitalWrite(5, LOW);   
  digitalWrite(4, HIGH);   
  digitalWrite(0, HIGH);   
  digitalWrite(2, LOW);   
  digitalWrite(14, LOW);   
  digitalWrite(12, HIGH);   
  digitalWrite(13, HIGH);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // 8 EIGHT   
  digitalWrite(16, HIGH);   
  digitalWrite(5, LOW);   
  digitalWrite(4, LOW);   
  digitalWrite(0, LOW);   
  digitalWrite(2, LOW);   
  digitalWrite(14, LOW);   
  digitalWrite(12, LOW);   
  digitalWrite(13, LOW);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // 9 NINE   
  digitalWrite(16, HIGH);   
  digitalWrite(5, LOW);   
  digitalWrite(4, LOW);   
  digitalWrite(0, HIGH);   
  digitalWrite(2, LOW);   
  digitalWrite(14, LOW);   
  digitalWrite(12, LOW);   
  digitalWrite(13, LOW);   
  delay(2000); // Wait for 2000 millisecond(s)   
   // . DOT   
  digitalWrite(16, LOW);   
  digitalWrite(5, HIGH);   
  digitalWrite(4, HIGH);   
  digitalWrite(0, HIGH);   
  digitalWrite(2, HIGH);   
  digitalWrite(14, HIGH);   
  digitalWrite(12, HIGH);   
  digitalWrite(13, HIGH);   
  delay(2000); // Wait for 2000 millisecond(s)   
  }     

We hope that now you are familiar with the working of a seven segment display with the nodemcu. If you have any doubts then do inform us in the comments section below. Also, do check out the tutorials on Arduino and Raspberry Pi written by us.

HAPPY LEARNING!

Spread the love, Share this post with friends