#include<reg52.h> //头æ件
sbit A1=P1^0; //å®ä¹A线åæ£ç«¯å£
sbit A2=P1^1; //å®ä¹A线åè´ç«¯å£
sbit B1=P1^2; //å®ä¹B线åæ£ç«¯å£
sbit B2=P1^3; //å®ä¹B线åè´ç«¯å£
sbit en1=P2^0;
sbit en2=P2^1;
int t=0;
#define F1 {A1=1;B1=0;A2=0;B2=0;} //A线åéæ£åçµå
#define F2 {A1=0;B1=1;A2=0;B2=0;} //B线åéæ£åçµå
#define F3 {A1=0;B1=0;A2=1;B2=0;} //A线åéååçµå
#define F4 {A1=0;B1=0;A2=0;B2=1;} //B线åéååçµå
#define OFF {A1=0;B1=0;A2=0;B2=0;} //å
¨é¨æçµ
unsigned int b=2000; //ä¸æåå¼åé
void Init_Timer0(void) //åå§åå®æ¶å¨0
{
TMOD=0x01; //å®æ¶å¨0ï¼ä½¿ç¨æ¨¡å¼1ï¼16ä½å®æ¶å¨
TH0=(65536-b)/256; //ç»å®åå¼
TL0=(65536-b)%256;
EA=1; //æå¼æ»ä¸æ
ET0=1; //æå¼å®æ¶å¨ä¸æ
TR0=1; //å¼å®æ¶å¨
}
void main() //主å½æ°
{
en1=1;
en2=1;
Init_Timer0(); //åå§åå®æ¶å¨0
while(1);
}
追é®è¿è¡äºä¸ä¸ï¼çµæºå¨ä¸äºï¼ç¨åºä¸å®æ´å§ï¼æå°è¯æ¹æ¹ï¼ä¸è¡åæ¾ä½ ï¼çè¯æè°¢ã