#include<c:KeilC51INCSTCSTC12c5a60S2.H>
#define uchar unsigned char
#define uint unsigned int
sbit COM3=P2^3;
sbit COM2=P2^2;
sbit COM1=P2^1;
sbit COM0=P2^0;
sbit key1=P2^7;
uchar i;
unsigned char ScanCoun=0;
unsigned char C0[10]={0x01,0x00,0x01,0x01,0x00,0x01,0x01,0x01,0x01,0x01};
unsigned char C1[10]={0x03,0x02,0x02,0x02,0x03,0x01,0x01,0x02,0x03,0x03};
unsigned char C2[10]={0x01,0x00,0x03,0x02,0x02,0x02,0x03,0x00,0x03,0x02};
unsigned char C3[10]={0x03,0x02,0x01,0x03,0x02,0x03,0x03,0x02,0x03,0x03};
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
key() // °´¼üº¯Êý
{
if(key1==0)
{
delay(10);
if(key1==0)
{
i++;
if(i>9)
i=0;
while(key1==0);
}
}
}
void main(void)
{
TMOD = 0x01;
ET0 = 1;
EA = 1;
TR0 = 1;
EA=1; //¿ªÈ«¾Ö×ÜÖжÏ
while(1)
{
}}
void Timer0() interrupt 1 //¶¨Ê±Æ÷ÖжÏ
{
TL0=0x78; //¶¨Ê±5ms
TH0=0xec;
P2M1 =0x0f;
P2M0 =0x00;
key();
switch(ScanCoun) //¶¯Ì¬É¨ÃèÏÔʾ
{
case 0: //COM3正向驱动
COM0=1;
COM1=1;
COM2=1;
COM3=0;
P0=C0
;
P2M1 =0x07;
P2M0 =0x00;
break;
case 1 : //COM3反向驱动
COM0=0;
COM1=0;
COM2=0;
COM3=1;
P0=~C0;
P2M1 =0x07;
P2M0 =0x00;
break;
case 2: //COM2正向驱动
COM0=1;
COM1=1;
COM2=0;
COM3=1;
P0=C1;
P2M1 =0x0b;
P2M0 =0x00;
break;
case 3: //COM2反向驱动
COM0=0;
COM1=0;
COM2=1;
COM3=0;
P0=~C1;
P2M1 =0x0b;
P2M0 =0x00;
break;
case 4: //COM1正向驱动
COM0=1;
COM1=0;
COM2=1;
COM3=1;
P0=C2;
P2M1 =0x0d;
P2M0 =0x00;
break;
case 5: //COM1反向驱动
COM0=0;
COM1=1;
COM2=0;
COM3=0;
P0=~C2;
P2M1 =0x0d;
P2M0 =0x00;
break;
case 6 : //COM0正向驱动
COM0=0;
COM1=1;
COM2=1;
COM3=1;
P0=C3;
P2M1 =0x0e;
P2M0 =0x00;
break;
case 7: //COM0反向驱动
COM0=1;
COM1=0;
COM2=0;
COM3=0;
P0=~C3;
P2M1 =0x0e;
P2M0 =0x00;
break;
}
ScanCoun++; //加一
if (ScanCoun>7) ScanCoun=0;
}
此帖出自
小平头技术问答
赞赏一下楼主的图,画得比较规范。比现在多数图纸中没有连线,只有网络标号的画法好得多!
一周热门 更多>