This code is a simple one . Here just a 7 seg display is attached to Port 0 of 8051 micro controller . The values can be calculated easily .
One unit of 7 seg display has 7 different leds as its segments and also a dot at the bottom left corner. Hence the 8 data lines are connected to P0 and the following values are passed to get the required number to be displayed on the display .
|
Common Cathode |
|
Common Anode |
There are two types of 7 seg. common anode and common cathode,depending upon which one u buy the values change . Just change those values according to the above table.you can refer data sheet to understand the exact difference between them.
CODE:
#include <reg51.h>
unsigned char array[]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x02,0x78,0x00,0x18}; //common anode values
void main()
{
unsigned char i;
for(i=0;i<11;i++)
{
P0=array[i];
}
}
Like this:
Like Loading...
Related