基于51单片机点阵显示程序

#include
#define uint unsigned int
#define uchar unsigned char
sbit SCK=P1^4;
sbit RCK=P1^5;
sbit SER=P1^6;
sbit G1=P1^7;
uchar code TAB1[]={ 0x00,0x80,0x40,0x88,0x37,0xFC,0x10,0x88,
0x0F,0xFE,0x80,0x88,0x67,0xF8,0x20,0x80,
0x08,0x90,0x17,0xF8,0xE0,0x80,0x20,0x88,
0x2F,0xFC,0x20,0x80,0x20,0x80,0x20,0x80};
uchar code TAB[]={ 0x2E,0xE0,0x3A,0xBE,
0x4E,0xE0,0x8A,0xA0,
0x2E,0xE0,0x3A,0xBE,
0x2E,0xE4,0x65,0x04,
0xA4,0x84,0x2F,0xE4,
0x34,0x84,0x27,0xE4,
0x24,0x84,0x27,0xE4,
0x24,0x94,0x27,0xE8,
}; //衢
void delay(uint t)
{
while(t--);
}

void trans1(uchar temp2)
{ uchar i,j;
for(i=0;i<8;i++)
{
SCK=0;
j=temp2&0x01;
SER=!j^0;
temp2=temp2>>1;
SCK=1;
}


}

void trans(uchar datal_1,uchar datah_1)
{
uchar temp1;
temp1=datah_1;
trans1(temp1);
temp1=datal_1;
trans1(temp1);
RCK=0;
RCK=1;
temp1=0;
trans1(temp1);
temp1=0;
trans1(temp1);
RCK=0;
RCK=1;
}

void main()
{
uchar line,temp,count,datal,datah;
while(1)
{
count=0;
for(line=0;line<16;line++)
{
G1=0;
temp=P1&0xf0;
P1=temp+line;
datal=TAB[count];
count++;
datah=TAB[count];
count=count+1;
trans(datal,datah);
delay(10);
}
}


}






相关文档
最新文档