Aim:
The main aim of this project is how to interface 7-segment and display 0 to 99 values on 7-segments.
Description:
Introduction
Till now you have learn what is an embedded system, basic memory architecture of a microcontroller, how to implement assembly language and use of some softwares like pinnacle 52, keil-C and flash magic; we also have come across how to interface LEDs from a microcontroller and how to generate different pattern through it. now its time to move forward and learn one more step ahead towards the completion of our 6-weak training. so here today we will learn about 7-Segment display; How to interface and program it; and some of the applications of it.
7-Segment Display
A 7-Segment display is a useful electronic component use to produce numeric, alphabetic and some non-alphabetic symbols using a specific arrangement of LEDs as shown in figure here.
A 7-Segment display has 10-Pins representing each a, b, c, b, e, f, gand h LEDs respectively along with two extra pins for GND andVSS. following shown an original 7-Segment display device along with its pin diagram. LED h is also denoted by symbol dp.
As we have studied in LED interfacing a 7-segment display is also interfaced in same way as it is also made of LEDs. So we can interface LEDs in three ways bu here difference is that 7-Segment displays comes in two types by manufacturers i.e. “Common Anode” and “Common Cathode“; the logics are shown in figure below.
and thus which logic is o implement is on the bases of these specifications provided by manufacturer.
Digit Drive Pattern:
To display the digits on 7 segment, we need to glow different logic combinations of segments. For example if you want to display the digit 3 on seven segment then you need to glow the segments a, b, c, d and g. The below table show you the Hex decimal values what we need to send from PORTB to Display the digits from 0 to 9.
DIGIT | DP | G | F | E | D | C | B | A | HEX VALUE |
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 |
Block Diagram
Schematic
Code
// ******************************************************
// Project: 0 to 99 display in 7-segments using ARM7(LPC2148)
// Author: Hack Projects India
// Module description: Operate two 7-segments
// ******************************************************
#include<lpc214x.h>
int i,j,k,l,a[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67};
void delay_ms(double ms);
void delay_ms(double ms)
{
unsigned int i,j;
for(i=0;i<ms;i++)
for(j=0;j<1000;j++);
}
int main()
{
PINSEL0=0x00000000; //set all GPIO pins
PINSEL1=0x00000000;
PINSEL2=0x00000000;
IO0DIR |=0xff;
IO1DIR |=(1<<16)| (1<<17);
//set 16,17,18,19,20,21,22 as output pins
while(1)
{
for(k=0;k<10;k++)
{
for(l=0;l<10;l++)
{
IOSET1=0x02<<16;
IOSET0=a[k];
delay_ms(100);
IOCLR1=0x02<<16;
IOCLR0=a[k];
IOSET1=0x01<<16;
IOSET0=a[l];
delay_ms(1000);
IOCLR1=0x01<<16;
IOCLR0=a[l];
}
}
}
}
Downloads:
The code was compiled in Keil uvision4 and simulation was made in Proteus v7.7.
To download code and proteus simulation click here.
Further Reading suggestions:
You may also like,
- Interfacing keypad with ARM(LPC2148)
- nterfacing DAC with ARM(LPC2148)
- Interfacing with UART of ARM(LPC2148) controller
- Interfacing SPI communication with PIC
- ARM(LPC2148) Displaying Custom Characters on LCD
- RTC interfacing using I2C in ARM(LPC2148)
- Interfacing Graphical LCD with ARM(LPC2148)
- Interfacing ultrasonic sensor with ARM(LPC2148)
- Interfacing GPS Modu with ARM(LPC2148)
- Interfacing GSM Module with ARM(LPC2148)
- Interfacing PWM in ARM(LPC2148)
- Interfacing ADC with ARM(LPC2148)
- Scrolling string on LCD using ARM(LPC2148)
- Interfacing keypad with ARM(LPC2148)
- nterfacing DAC with ARM(LPC2148)
- Interfacing with UART of ARM(LPC2148) controller
- Interfacing SPI communication with PIC
- ARM(LPC2148) Displaying Custom Characters on LCD
- RTC interfacing using I2C in ARM(LPC2148)
- Interfacing Graphical LCD with ARM(LPC2148)
- Interfacing ultrasonic sensor with ARM(LPC2148)
- Interfacing GPS Modu with ARM(LPC2148)
- Interfacing GSM Module with ARM(LPC2148)
- Interfacing PWM in ARM(LPC2148)
- Interfacing ADC with ARM(LPC2148)
- Scrolling string on LCD using ARM(LPC2148)
No comments:
Post a Comment