[vc_row][vc_column width=”1/1″][vc_column_text]We used 1 digit segment display to show 0-9 in previous tutorial, if we want to show more number or letters, we will need to use multi digit segment display. We’re going to use 4 digit in one Common-Anode display to show stopwatch in this experiment.
The inner schematic diagram of the segment display is as following:
Pin definition:
Pin order: Look from the front side of the segment display, it starts from Pin 1, it goes in a counterclockwise way.
12 – 9 – 8 – 6 — public pin
A-11 B-8 C-4 D-2 E-1 F-10 G-5 DP-3
[/vc_column_text][vc_tour][vc_tab title=”Parts List” tab_id=”1387769429-1-69″][vc_column_text]pcDuino kit x1
4 digit Common-Anode display x1
220 ohm resistor x8
male to male jumper wire x 18
[/vc_column_text][/vc_tab][vc_tab title=”Wire diagram” tab_id=”1387769429-2-78″][vc_column_text]![]()
|
Arduino Pin |
Segment display Pin |
|
5 |
6(units) |
|
4 |
8(tens) |
|
3 |
9(hundreds) |
|
2 |
12(thousands) |
|
Arduino Pin |
Segment display Pin |
|
6 |
A(11) |
|
7 |
B(7) |
|
8 |
C(4) |
|
9 |
D(2) |
|
10 |
E(1) |
|
11 |
F(10) |
|
12 |
G(5) |
|
13 |
DP(3) |
[/vc_column_text][/vc_tab][vc_tab title=”Simple Code” tab_id=”1387776844988-2-2″][vc_column_text]All code can be downloaded from here.
Please save “sevseg” from the zip file into /home/ubuntu/Arduino/libraries
After that reopen Arduino IDE.
Main code is as below:
//Written by Dean Reading, 2012. deanreading@hotmail.com/*This example is a centi-second counter to demonstrate theuse of my SevSeg library.*/#include "SevSeg.h"//Create an instance of the object.SevSeg sevseg;//Create global variablesunsigned long timer;int CentSec=0;void setup() {//I am using a common anode display, with the digit pins connected//from 2-5 and the segment pins connected from 6-13sevseg.Begin(1,2,3,4,5,6,7,8,9,10,11,12,13);timer=millis();}void loop() {//Produce an output on the displaysevseg.PrintOutput();//Check if 10ms has elapsedunsigned long mils=millis();if (mils-timer>=10) {timer=mils;CentSec++;if (CentSec==10000) { // Reset to 0 after counting for 100 seconds.CentSec=0;}//Update the number to be displayed, with a decimal//place in the correct position.sevseg.NewNum(CentSec,(byte) 2);}}[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]

Leave a Reply
You must be logged in to post a comment.