How to use Seven Segment display

Advantage of 7-segment display is, it can easily work/interface without Microcontroller or a Microprocessor while other display modules need Microcontroller or a Microprocessor to operate. Now let see How to use seven segment display.

Generally a seven segment display is used along with a microprocessor/microcontroller in that case, the eight segment pins will be connected to the I/O pins of the Microcontroller and the com pin will be connected to the ground or Vcc depending upon its type CC/CA.

Then these IO pins can be powered in a particular sequence to display the desired character or numbers. This particular arrangement is explained through the table below.  For displaying each number in the seven segment display its respective sequence is given in the table given below.

HOW TO USE SEVEN SEGMENT DISPLAY FOR CC AND CA

1) FOR COMMON CATHODE TYPE

If we want to display the number “9”, then we need to glow all the LEDs except LED which belongs to line “e” (see 7 segment pin diagram above), so we need a bit pattern 01101111 for CC display.

Similarly to display “1”we need to glow LEDs associated with b and c, so the bit pattern for this would be 00000110 for CC display. If you want decimal point led to turn on give logic ‘1’ to it and if not then ‘0’.

DIGIT TO DISPLAY DP g f e d c b a
0 0 0 1 1 1 1 1 1
1 0 0 0 0 0 1 1 0
2 0 0 1 1 1 0 1 1
3 0 1 0 0 1 1 1 1
4 0 1 1 0 0 1 1 0
5 0 1 1 0 1 1 0 1
6 0 1 1 1 1 1 0 1
7 0 0 0 0 0 1 1 1
8 0 1 1 1 1 1 1 1
9 0 1 1 0 1 1 1 1

2) FOR COMMON ANODE TYPE

If we want to display the number “7”, then we need to glow three LEDs at segment c,b,a (see 7 segment pin diagram above) so we need a bit pattern 11111000 for CA display. Similarly to display “1”we need to glow LEDs associated with b and c, so the bit pattern for this would be 11111001 for CA display.

DIGIT TO DISPLAY DP g f e d c b A
0 1 1 0 0 0 0 0 0
1 1 1 1 1 1 0 0 1
2 1 0 1 0 0 1 0 0
3 1 0 1 1 0 0 0 0
4 1 0 0 1 1 0 0 1
5 1 0 0 1 0 0 1 0
6 1 0 0 0 0 0 1 0
7 1 1 1 1 1 0 0 0
8 1 0 0 0 0 0 0 0
9 1 0 0 1 0 0 0 0

FUNCTIONs

Before we start let we discuss about function. Same as we use function in C programming language we can use function in Arduino programming. Functions are very useful tool in programming because it gives us flexibility to write code once and use again and again instead of writing again and again.

Functions are of two types inbuilt/predefined and user defined we already used inbuilt function for example pinMode(), digitalWrite() etc. Now we are going to use user defined function. Every function has a return type. If a function doesn’t return any value, then void is used as return type.

Now, how to use function, define function outside the body of void setup() and void loop() with its type of return, function-name and parameter to be passed at the  time of calling a function. See below

Type of function is void and int and many more, type means what will function return at time of call, if it is void type then it will return nothing, but if it is int that means function will return an integer value.

void function1()
void function2()
int function3()
int function4()

We can pass parameters to a function so that function will work according to our input values for example see in first void function we are passing one parameter in second void function we are passing two parameters. Same as in int type we are passing one and two parameters.

void function1(int a)
void function2(int a, int b)
int function3(int a)
int function4(int a, int b)

SYNTAX

void function1() {
    statement 1;
    statement 2;
    .......
}

Seven Segment can be used in two ways

  1. Directly without shift register
  2. Using Shift Register (recommended)

 

Read Next : DISPLAY 1 ON SEVEN SEGMENT DISPLAY

Leave a Reply

avatar
  Subscribe  
Notify of

Arduino Tutorials with Basic Electronics: CONTENT

Translate »