#include
#include
#define uchar unsigned char
#define uint unsigned int
unsigned char table[]={0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f, 0x40,0x00};
void keyscan()
{
enum keydown kdwn;
P1=0xff;
If((P1&0xff)!=0x1f)
{
delay(1000);
If((P1&0x1f)!=0x1f)
{
kdwn=P1&0x1f;
switch(kdwn)
{
case clckws:clokwise();break;
case antclckws:anticlokwise();break;
case mstsp:motorstop();break;
case spdp:speedup();break;
case spdwn:speeddown();break;
}
}
}
while((P1&0x1f)!=0x1f);
}
void time0_int(void) interrupt 1
{
time++;
TH0 = 0xec;
TL0 = 0x78;
if(change == 0)
{
PWM2 = 1;
if(time == high)
PWM1=0;
else if(time == period)
{
PWM1 = 1;
time = 0;
}
}
else
{ PWM1 = 1;
if(time == high)
PWM2=0;
else if(time == period)
{
PWM2 = 1;
time = 0;
}
}
}
void main ()
{
int i;
TM0D=0x01;
TH0=(65536-40000)/256;
TL0=(65536-40000)%2560;
EA=1;
ET=0;
TR=0;
while(1)
{
keyscan();
}
}