Õã½Àí¹¤´óѧÍ϶¯ÏµÍ³¿Î³ÌÉè¼Æ
if(speed00==0) {yy[3]='\\0';} delay(5) ; write_string(LCD_SL+8,\ \ //ÆÁÄ»Çå¿Õ delay(35); write_string(LCD_SL+8,yy); }
//-------------------------------------------------------------------
//--------------------------------------------------------------¼ÆÊ±Æ÷1ÖÐ¶Ï void time0() interrupt 3 {
time_calculate(); BG++;S++; if(BG==1) { TH1=PHTH; TL1=PHTL; } else { BG=0; TH1=PLTH; TL1=PLTL; } if(direction==1) {PWM1=~PWM1;PWM2=0;} else {PWM2=~PWM2;PWM1=0;} }
//---------------------------------------------------------------------
//--------------------------------------------------------¼ÆÊýÆ÷ÖÐ¶Ï void time2() interrupt 0
µÚ25Ò³
Õã½Àí¹¤´óѧÍ϶¯ÏµÍ³¿Î³ÌÉè¼Æ
{
RAND++; if(S==200) {speed_calculate(); } }
//-------------------------------------------------------------
//------------------------------------------------------------Ö÷³ÌÐò void main() {
rank=5; // ÉèÖÃĬÈÏתËÙ state=0; // µç»úֹͣ״̬ direction=1; // µç»úתÏòΪÕý·½Ïò PWM1=0; // ÎÞPWMÐźŠPWM2=0; // lcd_init(); // ³õʼ»¯ÆÁÄ» while(1) { key(); if(key_in>0) { if(key_in==1||key_in==2) { if(key_in==1&&rank<9) { rank++; } if(key_in==2&&rank>3) { rank--; } time_calculate(); } else if(key_in==7||key_in==8) {
if(key_in==8&&state==1) { PWM1=0;PWM2=0; TR1=0;ET1=0;state=0; EX0=0; write_string(LCD_SL,\ \
µÚ26Ò³
//¶¨Ê±Æ÷ºÍ¼ÆÊýÆ÷ÖжÏÉèÖÃ
Õã½Àí¹¤´óѧÍ϶¯ÏµÍ³¿Î³ÌÉè¼Æ
} else if(key_in==7&&state==0) { TR1=1;ET1=1;EA=1;TMOD=0x10; BG=1; state=1;IT0=1;EX0=1;PX1=1; //¶¨Ê±Æ÷ºÍ¼ÆÊýÆ÷ÖжÏÉèÖà //¶¨Ê±Æ÷1ÒÔ·½Ê½1¼Çʱ //¼ÆÊýÆ÷0ÒÔϽµÑØ´¥·¢ÖÐ¶Ï S=0;RAND=0; pwm_on(); } } else if(key_in==4||key_in==5) { if(direction==2&&key_in==4) { direction=1;PWM1=0;PWM2=0; TR1=0;ET1=0; delay_1ms(400); } else if(direction==1&&key_in==5) { direction=2;PWM1=0;PWM2=0; TR1=0;ET1=0; //»»ÏòʱÏÈÍ£Ö¹ÔÚ»»Ïò delay_1ms(400); } if(state==1) { pwm_on(); } }
key_in=-1;
write_string(LCD_FL,\TE: \if(state==1) {
char xx[5];int R; R=rank-2;
sprintf(xx, \
write_string(LCD_FL+13,xx);
µÚ27Ò³
Õã½Àí¹¤´óѧÍ϶¯ÏµÍ³¿Î³ÌÉè¼Æ
} else {
write_string(LCD_FL+13,\ //Ë¢ÐÂÆÁÄ» }
if(direction==1)
write_string(LCD_FL+6,\else
}
}
}
write_string(LCD_FL+6,\
µÚ28Ò³