This tutorial of Robo India explains how to use a seven segment display on NodeMCU using Arudino IDE
Detailed Tutorial.
1. Introduction:
A seven segment display is a simple displaying device that uses 8 LEDs to display decimal numerals. It is generally used in digital clocks, calculators, electronic meters, and other devices that displays numerical information.
A seven segment display has 8 LEDs in it. Each LED is controlled through specific pin. These can be two type common anode and common cathode. In common cathode type the cathode is common for all 8 LEDs and in common anode type the anode is common for all 8 LEDs. A seven segment display has 10 pin interface, 2 pins are for
Common and 8 pins are for each LED. Both common pins are internally shorted
This tutorial is for NodeMCU on Arduino IDE. Please note that the same tutorial can be performed on LUA as well.
1.2 Hardware required
S.No. | Item | Quantity |
1 | NodeMCU | 1 |
2 | Breadboard | 1 |
3 | Resistor 1k | 8 |
4 | Seven Segment Display | 1 |
5 | Jumper Male to male | 11 |
2. Building Circuit.
Schematic Diagram:
Circuit Layout:
3. Programming:
Once the circuit part is done, NodeMCU is needed to be programmed. Here is the code to run this circuit on NodeMCU.
You may download this code (Arduino Sketch) from here.
// Robo India tutorial on Seven Segement Display // Hardware: NodeMCU const int A = 12; const int B = 14; const int C = 2; const int D = 5; const int E = 4; const int F = 13; const int G = 15; const int DP = 0; void setup() { pinMode(A, OUTPUT); pinMode(B, OUTPUT); pinMode(C, OUTPUT); pinMode(D, OUTPUT); pinMode(E, OUTPUT); pinMode(F, OUTPUT); pinMode(G, OUTPUT); pinMode(DP, OUTPUT); } void loop() { two(); delay(1000); five(); delay(1000); } void two(){ digitalWrite(A, LOW); digitalWrite(B, LOW); digitalWrite(C, HIGH); digitalWrite(D, LOW); digitalWrite(E, LOW); digitalWrite(F, HIGH); digitalWrite(G, LOW); digitalWrite(DP, HIGH); } void five(){ digitalWrite(A, LOW); digitalWrite(B, HIGH); digitalWrite(C, LOW); digitalWrite(D, LOW); digitalWrite(E, HIGH); digitalWrite(F, LOW); digitalWrite(G, LOW); digitalWrite(DP, HIGH); }
4. Output
Number 2 is displayed on seven segment display for one second then number 5 is displayed for another one second, this runs in a loop.
5. Understanding the code:
There are two functions –
1. void five(): This function sets some segments high and other low so that number 5 is displayed on the display.
2. void two(): As same in the above function, number 2 is displayed on the display.
If still not working pull the led out and test it may be defective
If you have any query please write us at support@roboindia.com
Thanks and Regards
Content Development Team
Robo India
https://roboindia.com