How can I display different numbers in a dual 7 segment with arduino and proteus?
This is my setup:
void setup() {
pinMode(13,OUTPUT); //a
pinMode(12,OUTPUT); //b
pinMode(11,OUTPUT); //c
pinMode(10,OUTPUT); //d
pinMode(9,OUTPUT); //e
pinMode(8,OUTPUT); //f
pinMode(7,OUTPUT); //g
pinMode(6,OUTPUT); //power 1 (left)
pinMode(5,OUTPUT); //power 2 (left)
}
I use this code (in void loop) to display the number 0 in the 7 segment:
digitalWrite(6, 0); //power 1 (left)
digitalWrite(5, 0); //power 2 (left)
digitalWrite(13, HIGH);
digitalWrite(12, HIGH);
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, LOW);
If I simulate this in proteus I got this output:
If I add another number like 8:
digitalWrite(13, HIGH);
digitalWrite(12, HIGH);
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
The code will just go 0 and 8 on both of the 7segments.
I want it to display 0 on the right and eight on the left but I dont know how to control this dual 7 segment. I want to create a countdown timer, and I have not found any tutorials about it, the tutorials were 2 7 segments in the countdown, not a dual 7 segment display.
Note: I am not using any registers in this project.
The pins 1 and 2 are used to address each one of the seven segments. You need to sink pin 1 to the ground and supplying the value you want to display in the first seven segment then switch to the other by sinking pin 2 to the ground and supplying the value you want to display. This has to happen very fast so human eye won't notice it.
Refer to this circuit
You can use a library that saves you from all of this.
Download the library from here
To install it, open the Arduino IDE, go to Sketch > Include Library > Add .ZIP Library, then select the SevSeg ZIP file that you downloaded.
Then try the following code it should display "80"