全文预览

基于51单片机智能红外循迹小车.

上传者:随心@流浪 |  格式:pdf  |  页数:14 |  大小:0KB

文档介绍
pwm_val_right>=20) pwm_val_right=0; }else {EN2=0; //若未开启 PWM 则EN2=0 右电机停止}}//TIMER0 中断服务子函数产生 PWM 信号 void timer0()interrupt 1using 2 {TH0=0XFC; //1Ms 定时 TL0=0X66; pwm_val_left++; //pwm jishi suanzi jia 1 pwm_val_right++; //you pwm jishi suanzi jia 1 pwm_out_left_moto(); //chansheng zuodianji ENpwm xinhao pwm_out_right_moto(); //chansheng youdianji ENpwm xinhao }void keyscan(void) //按键扫描函数{A:if(K4==0) //判断是否有按下信号{delay(10); //延时 10ms if(K4==0) //再次判断是否按下{FM=0; //蜂鸣器响 while(K4==0); //判断是否松开按键 FM=1; //蜂鸣器停止}else {goto A;//跳转到 A重新检测}}else {goto A;//跳转到 A重新检测}}//主函数 void main(void) {unsigned char left_num,right_num; unsigned char diff_num; unsigned char left_led_1; unsigned char left_led_2; unsigned char left_led_3; unsigned char left_led_4; unsigned char right_led_1; unsigned char right_led_2;

收藏

分享

举报
下载此文档