main.c
#include<reg51.h>
#include<function.h>
#include<keyscan.h>
#define speed 1
sbit PH1 = P1^; //定義管腳
sbit PH2 = P1^;
sbit I01 = P1^;
sbit I11 = P1^;
sbit I02 = P1^;
sbit I12 = P1^;
void delay(int time){
int i,j;
for(j=; j <= time; j++)
for(i = ; i <= ; i++);
}
void init()
{
PH1 = ;
I01 = ;
I11 = ;
PH2 = ;
I02 = ;
I12 = ;
delay(speed);
PH1 = ;
I01 = ;
I11 = ;
PH2 = ;
I02 = ;
I12 = ;
delay(speed);
}
void Go1() // !a=>!b=>a=>b=>!a
{
PH1 = ;
I01 = ;
I11 = ;
PH2 = ;
I02 = ;
I12 = ;
delay(speed);
//okay;
PH1 = ;
I01 = ;
I11 = ;
PH2 = ;
I02 = ;
I12 = ;
delay(speed);
PH1 = ;
I01 = ;
I11 = ;
PH2 = ;
I02 = ;
I12 = ;
delay(speed);
PH1 = ;
I01 = ;
I11 = ;
PH2 = ;
I02 = ;
I12 = ;
delay(speed);
PH1 = ;
I01 = ;
I11 = ;
PH2 = ;
I02 = ;
I12 = ;
delay(speed);
}
void Go2()
{
PH1 = ;
I01 = ;
I11 = ;
PH2 = ;
I02 = ;
I12 = ;
delay(speed);
PH1 = ;
I01 = ;
I11 = ;
PH2 = ;
I02 = ;
I12 = ;
delay(speed);
PH1 = ;
I01 = ;
I11 = ;
PH2 = ;
I02 = ;
I12 = ;
delay(speed);
PH1 = ;
I01 = ;
I11 = ;
PH2 = ;
I02 = ;
I12 = ;
delay(speed);
PH1 = ;
I01 = ;
I11 = ;
PH2 = ;
I02 = ;
I12 = ;
delay(speed);
}
void main()
{
uchar key;
initialKeyScan();
init();
while()
{
key = keyScan();
switch(key)
{
case :{Go1(); break;}
case :{Go2(); break;}
}
key = ;
}
}