Thursday, 5 March 2015

Matrix Board using 7 Segmate AT89C52

#include<reg52.h>
sfr row=0x80;
sfr col=0x90;
sfr port=0xA0;
void msdelay(unsigned int);
void main()
{
unsigned int temp=0;
port=0;
while(1)
{
row=0x0E;
temp=col&0x0F;
msdelay(50);
if(temp==0x07)
{
port=0x3F;
msdelay(50);
}  
else if(temp==0x0B)
{
port=0x06;
msdelay(50);
}
else if(temp==0x0D)
{
port=0x5B;
msdelay(50);
}
else if(temp==0x0E)
{
port=0x4F;
msdelay(50);
}



row=0x0D;
temp=col&0x0F;
msdelay(50);
if(temp==0x07)
{
port=0x66;
msdelay(50);
}  
else if(temp==0x0B)
{
port=0x6D;
msdelay(50);
}
else if(temp==0x0D)
{
port=0x7D;
msdelay(50);
}
else if(temp==0x0E)
{
port=0x07;
msdelay(50);
}



row=0x0B;
temp=col&0x0F;
msdelay(50);
if(temp==0x07)
{
port=0x7F;
msdelay(50);
}  
else if(temp==0x0B)
{
port=0x6F;
msdelay(50);
}
else if(temp==0x0D)
{
port=0x77;
msdelay(50);
}
else if(temp==0x0E)
{
port=0x7C;
msdelay(50);
}

row=0x07;
temp=col&0x0F;
msdelay(50);
if(temp==0x07)
{
port=0x39;
msdelay(50);
}  
else if(temp==0x0B)
{
port=0x5E;
msdelay(50);
}
else if(temp==0x0D)
{
port=0x79;
msdelay(50);
}
else if(temp==0x0E)
{
port=0x71;
msdelay(50);
}
}
}
void msdelay(unsigned int item)
{
unsigned int i,j;
for(i=0;i<item;i++)
for(j=0;j<1275;j++);
}

No comments:

Post a Comment