0% found this document useful (0 votes)
169 views12 pages

Display Hexadecimal Numbers On Seven Segment Display

This document describes how to display hexadecimal numbers on a seven segment display using an LPC1768 microcontroller. It connects the display to three GPIO pins for shift clock, serial data, and latch clock. A shift register is used to sequentially latch 8-bit data for each segment. The code defines an array mapping hexadecimal values to segment patterns. It loops through the array, displaying each value on the six LED segments with a delay before moving to the next value.

Uploaded by

chappidi anusha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
169 views12 pages

Display Hexadecimal Numbers On Seven Segment Display

This document describes how to display hexadecimal numbers on a seven segment display using an LPC1768 microcontroller. It connects the display to three GPIO pins for shift clock, serial data, and latch clock. A shift register is used to sequentially latch 8-bit data for each segment. The code defines an array mapping hexadecimal values to segment patterns. It loops through the array, displaying each value on the six LED segments with a delay before moving to the next value.

Uploaded by

chappidi anusha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Display Hexadecimal

numbers on Seven
Segment Display
Seven Segment
a a a a

g b g b g b g b

e e e e
f c f c f c f c

d h d h d h d h

1 2 3
The segment LED
* turns on when given ‘0’
* turns off when given ‘1’
Hexa Number h g f e d c b a Equivalent Code
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 0 0 0 0 0x90
A 1 0 0 0 1 0 0 0 0x88
B 1 0 0 0 0 0 1 1 0x83
C 1 1 0 0 0 1 1 0 0xC6
D 1 0 1 0 0 0 0 1 0xA1
E 1 0 0 0 0 1 1 0 0x86
F 1 0 0 0 1 1 1 0 0x8E
Shift Clock 15 a
P2.0 11 1 b
2 c
Serial Data 3 d
P2.1 14
4 e
5 f
Latch Clock 6 g
P2.2 12
LPC1768 7 h

IC74HC595
SISO/PO
Shift Register
Code
#include<lpc17xx.h>

void display(unsigned char value);


void delay(unsigned int d);

unsigned char data[16] = {0xc0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80,
0x90, 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E};
Main Code
int main()
{ Number of Hexadecimal
numbers
unsigned char i,j;
LPC_GPIO2->FIODIR=7;

while(1) To turn on the six LED


{ segments
for(i=0; i<16; i++)
{
for(j=0;j<6;j++)
display(data[i]); Send the data
delay(50);
}
}
}
LPC_GPIO2->FIODIR = 7;

0 0 0 0 0 0 0 F
31:28 27:24 23:20 19:16 15:12 11:8 7:4 3:0
0000 0000 0000 0000 0000 0000 0000 0111
P2.0  to propagate a clock pulse to move from LED to LED, Shift Clock
P2.1  Send the data to turn on LED, Serial Data
P2.2  to propagate a clock pulse to move from Segment to Segment, Latch Clock
Display Function Represents 8 bits
or
void display(unsigned char value) 8 LEDs in Hexa Display
{
unsigned char m;
Extract the MSB
for(m=0; m<8; m++)
{
if(value & 0x80)
LPC_GPIO2->FIOSET=2;
else Generate a pulse at GPIO2.0 to
LPC_GPIO2->FIOCLR=2; move for next LED

LPC_GPIO2->FIOSET=1;
LPC_GPIO2->FIOCLR=1;
value<<=1;
} Generate a pulse at GPIO2.2 to
LPC_GPIO2->FIOSET=4; move for next Segment
LPC_GPIO2->FIOCLR=4;
}
if(value & 0x80)
LPC_GPIO2->FIOSET=2;
else
LPC_GPIO2->FIOCLR=2;
Value has the Data in the array, (Code for the HEXA number)
Value is 8 bit data, eg: 0xA4
1 0 1 0 0 1 0 0

0xA4 & 0x08


1 0 0 0 0 0 0 0

Check the MSB for 1; If ‘1’ set the output p2.1 [TURN OFF LED],
else clr the output p2.1 [TURN ON LED], .
Delay Function
void delay(unsigned int d)
{
unsigned int i,j;

for(i=0;i<d;i++)
for(j=0;j<10000;j++);
}
 
 
THANK U
Use FRC 1 to
interface

You might also like