标签归档:单片机

留个记号

 时隔这么久,再次做个小记号。

#include 
#define uchar unsigned char

sbit addr0=P1^4;
sbit addr1=P1^5;
sbit addr2=P1^6;
sbit addr3=P1^7;

uchar code scan[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};  
uchar code words[]={0xFF,0xF7,0x81,0xB5,0x81,0xF7,0xF7,0xFF};
uchar i,j,t;

void delay(uchar i)
{
	 for(i;i>0;i--);
}

void time50us() interrupt 1
{
	TH0=(65536-50000)/256;
	TL0=(65536-50000)%256;
	t++;
}

void main()
{
	EA=0;
	TMOD=0x01;
	TH0=(65536-50000)/256;
	TL0=(65536-50000)%256;
	ET0=1;
	EA=1;
	TR0=1;
	while(1)
	{
		if(t==10)
		{
			t=0;
			j++;
		}
		for(i=0;i<8;i++)
		{
		  addr0=0;
		  addr1=0;
		  addr2=0;
		  addr3=0;
		  P0=0xff;
		  addr3=1;
		  addr3=0;
		  addr0=1;
		  addr1=0;
		  addr2=0;
		  P0=words[(i+j)%8];
		  addr3=1;
		  addr3=0;
		  addr0=0;
		  addr1=0;
		  addr2=0;
		  P0=scan[i];
		  addr3=1;
		  addr3=0;
		  delay(20);
		}
	}
}