Introduction: 2 Digit Seven Segment Display
Most of the newbies are confused about using two or more seven segment displays, here is an instructable showing the implementation of the same with a microcontroller.
This is possible by virtue of high switching speed of LED and high of the microcontroller.
Step 1: Components Required
1. Seven segment display.
2. 220 Ohm resistors.
3. Jumper wire.
4. Breadboard.
5. Arduino UNO.
Step 2: Pin Configuration
Please note down that I have never used the pin notation as per Arduino, rather the port wise pins have been mentioned wiz; PORTC, PORTD, etc.
The pin configuration of Arduino UNO, seven segment display(both Common Anode & Common Cathode) is as shown.
Step 3: Circuit:
Make connection as shown in the schematic diagram.
Step 4: Source Code
The source code can be obtained from my GitHub profile. Click here
15 Comments
Question 8 months ago on Introduction
Design a 7 segment display that counts from 1 to 100
Question 2 years ago on Introduction
I need to replace the 2 digit led display in a washing machine control board. Can I use any brand that has 18 pins? I cannot find the exact model number part.
2 years ago
I have followed your solution, and made it work with two 7-segment elements. Then I wanted to expand to 3 elements by using D10 for the B00000100 address and DDRB = B00000111. What happemed was that two elements was lit for each address B0001, B0010, B0100.
To make light one element at the time, I had to use address B0110, B101, and B011 ie. the inverse of what should be normal addressing. Do you have an explenation for this?
See code below:
void setup()
{
// Setup digital register B & D (Arduino Port registers)
DDRD = B11111110; // Data Direction Register D (Digital pin D0-D7 from right). Here: 0 is input and 1-7 are output
DDRB = B00000111; // Data Direction Register B (Digital pin D8-D13 from right). Here: 8, 9 and 10 are output
}
void loop()
{
for (int k = 0; k < 10; k++) // ----- counting hundreds
{
for (int j = 0; j < 10; j++) // ----- counting tens
{
for (int i = 0; i < 10; i++) // ----- counting ones
{
for (int del = 0; del < 10; del++) // ----- display all numbers 10 times
{
PORTB = B00000110; // --- Addressing 1-er element (Why not B0001?)
digitDisplay(i);
delay(7);
PORTB = B00000101; // --- Addressing 10-er element(Why not B0010?)
digitDisplay(j);
delay(7);
PORTB = B00000011; // --- Addressing 100 element(Why not B0100?)
digitDisplay(k);
delay(7);
}
}
}
}
}
void digitDisplay(int x)
{
switch (x) {
case 1: PORTD = B00001100; break;
case 2: PORTD = B10110110; break;
case 3: PORTD = B10011110; break;
case 4: PORTD = B11001100; break;
case 5: PORTD = B11011010; break;
case 6: PORTD = B11111010; break;
case 7: PORTD = B00001110; break;
case 8: PORTD = B11111110; break;
case 9: PORTD = B11001110; break;
case 0: PORTD = B01111110; break;
}
}
6 years ago
are those displays common anode ?
Reply 5 years ago
Nope, they are the common cathode type.
Reply 5 years ago
They are the common cathode type, we can apply the same technique to the common anode as well, but there will be a small revision in logic. I'll try making it and update the instructable.
5 years ago
OK, n00b alert... I was interested in constructing a small compact elctronic scoring device. Let's say I have 2IN X 2IN X 2IN space, to accommodate a pair of 2-digit displays, the arduino UNO, toggle/up-down numeric control, battery power etc. Is this even remotely possible?
Reply 5 years ago
Yes, you can use the RF transceivers or a Bluetooth module or a Wifi module. It depends on the range you desire to control.
Reply 5 years ago
Assuming the dimensions of space to be 2X2X2 inches. Since the UNO board is bigger in size, you should make your custom PCB to meet your requirements. Else, using other boards like Nano and Micro should do the job.
And to control the score remotely, we should even provide some means of connectivity, be it a Bluetooth or WiFi. My suggestion is to use ESP12 based microcontroller it has WiFi connectivity.
5 years ago
Hi!
Thanks for the guide!
FYI: I found one error in "Step3: Circuit diagram". In the picture you have drawn the control wire for pin 8 and 9 to the same 7-seg display "vcc-pin". One of those needs to go to the second 7-seg display.
Reply 5 years ago
Yeah, Thanks for the information.
Question 5 years ago on Introduction
I there,
I am an enthusiast, and enjoyed watching your project!! How can your software be optimized to display actual values of some kind?? Like for instance temperature, or any other process variable?? Can an additional display be added??
I would appreciate your feedback.
Regards
Emile Steyn
Reply 5 years ago
the variable containing the numeric value needs to be sampled into the digits, and these variables need to be called to display now and then very often so that the values are displayed. And yeah additional display can be added, the only difference is the number of select lines increases.
6 years ago
Yea, but can you make the seven segment displays do that exact same thing without the Arduino Micro-controller? We used to do that with building our own oscillator and circuitry. Makes you learn more about how things really work. Nice project either way. I am glad to see younger folks getting into electronics even if it is always a Arduino controller circuit.
Reply 6 years ago
Thank you, we are here to learn unknown concepts of course. I'll be glad to learn your concept too. Could you please share it with us??