How to Interface 7 segment display with Microcontroller. (Code + Proteus Simulation)


This post is all about how to interface a seven segment display with microcontroller. In this particular example I will interface one seven segment display with PIC24. You may download Proteus Simulations and code from the links given at the bottom of this page.

            I am using MPLAB X IDE and C30 Compiler for 16bit microcontrollers. I supposed that you know how to blink an LED (if not then I suggest you to read this (link) first before continuing this post) and how to generate a delay without timers or with timers ((if not then I suggest you to read this (link1 and Link2) first before continuing this post).

            There are two types of seven segments available in the market
1)      Common anode.
2)      Common cathode.

I will go through from both of them in order to make you understand that what differences will be caused in hardware and software.

In hardware they are arrange in following type:


Common Anode Internal configuration.

Truth table for Common Anode:


Dp
(MSB)
G
F
E
D
C
B
A
(LSB)
Value in hex
0
1
1
0
0
0
0
0
0
0xC0
1
1
1
1
1
1
0
0
1
0xF9
2
1
0
1
0
0
1
0
0
0xA4
3
1
0
1
1
0
0
0
0
0xB0
4
1
0
0
1
1
0
0
1
0x99
5
1
0
0
1
0
0
1
0
0x92
6
1
0
0
0
0
0
1
0
0x82
7
1
1
1
1
1
0
0
0
0xF8
8
1
0
0
0
0
0
0
0
0x80
9
1
0
0
1
1
0
0
0
0x98

Common Cathode Internal configuration.

Truth table for Common Cathode:

Dp
(MSB)
G
F
E
D
C
B
A
(LSB)
Value in hex
0
0
0
1
1
1
1
1
1
0x3F
1
0
0
0
0
0
1
1
0
0x06
2
0
1
0
1
1
0
1
1
0x5B
3
0
1
0
0
1
1
1
1
0x4F
4
0
1
1
0
0
1
1
0
0x66
5
0
1
1
0
1
1
0
1
0x6D
6
0
1
1
1
1
1
0
1
0x7D
7
0
0
0
0
0
1
1
1
0x07
8
0
1
1
1
1
1
1
1
0x7F
9
0
1
1
0
0
1
1
1
0x67



And the 7 segment standard configuration is 

7 Segment standard configuration.
Proteus Simulation:

Following is the circuit for 7 segment it is counter from 0 to 9 which will reset to 0 again after displaying 9.
you can get code for both types of 7 segment from download section at the bottom of this post.


Proteus Simulation Common Anode
Code:

This code is written for Common anode but you may download for Common cathode in download section at the bottom of this post.

Main file 
Display7Segment_CommonAnode(variable) is the function which is responsible for displaying digit on 7 segment. for displaying 1 you may pass this function Display7Segment_CommonAnode(1)







Reading Suggestions:



Downloads:

You can download Code and Proteus Simulation
 

                                   For COMMON ANODE Click Here
                                   For COMMON CATHODE Click Here


©IbrahimLabs.blogspot.com










Popular posts from this blog

Defining code regions in MPLAB X IDE

Digital AC voltmeter Schematic + Code + Proteus Simulation

Automatic Streetlight control using LDR and PIC (Code + Proteus Simulation)