完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#include "REG52.H"
#define const_interrupt_time 792 #define uchar unsigned char #define uint unsigned int void initial_myself(); void initial_peripheral(); void delay_short(uint uiDelayShort); void delay_long(uint uiDelaylong); void Int0(); void detectorIR(); void run(); ***it IR_sr=P3^2; ***it P1_0=P1^0; ***it P1_1=P1^1; ***it P1_2=P1^2; ***it P1_3=P1^3; uchar ucMotorStep=0; uchar ucdata; void main() { initial_myself(); delay_long(100); initial_peripheral(); while(1) { detectorIR(); run(); } } void detectorIR() { if(ucdata==0x73) ucMotorStep=1; else if(ucdata==0x56) ucMotorStep=2; else if(ucdata==0x7b) ucMotorStep=3; else if(ucdata==0x52) ucMotorStep=4; else if(ucdata==0x71) ucMotorStep=5; else ucMotorStep=5; } void run() { switch(ucMotorStep) { case 1: P1_0=1; P1_1=0; P1_2=1; P1_3=0; break; case 2: P1_0=0; P1_1=1; P1_2=0; P1_3=1; break; case 3: P1_0=0; P1_1=0; P1_2=1; P1_3=0; break; case 4: P1_0=1; P1_1=0; P1_2=0; P1_3=0; break; case 5: P1_0=0; P1_1=0; P1_2=0; P1_3=0; break; } } void Int0() interrupt 0 { uchar i,j; EX0=0; i=10; while(i--) { TH0=(65535-const_interrupt_time)/256; TL0=(65535-const_interrupt_time)%256; TR0=1; while(!TF0); TF0=0; TR0=0; while(IR_sr) { EX0=1; return; } } while(!IR_sr); j=5; while(j--) { TH0=(65535-const_interrupt_time)/256; TL0=(65535-const_interrupt_time)%256; TR0=1; while(!TF0); TF0=0; TR0=0; while(!IR_sr) { EX0=1; return; } } while(IR_sr); for(i=0;i<4;i++) { for(j=0;j<8;j++) { while(!IR_sr); TH0=(65535-const_interrupt_time)/256; TL0=(65535-const_interrupt_time)%256; TR0=1; while(!TF0); TF0=0; TR0=0; if(IR_sr) { ucdata|=0x80; while(IR_sr); } ucdata>>=1; } } EX0=1; return; } void delay_long(unsigned int uiDelayLong) { unsigned int i; unsigned int j; for(i=0;i for(j=0;j<500;j++) { ; } } } void initial_myself() { TMOD=0x01; } void initial_peripheral() { ET0=1; IT0=1; EX0=1; EA=1; } |
|
相关推荐
2个回答
|
|
大神们帮个忙,不会写了
|
|
|
|
这么给程序谁给你改啊? 还不如你说什么要求,大家给你写新的方便
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
798 浏览 0 评论
【每周推荐】采用11代Intel CPU,基于youyeetoo X1开发板搭建少儿AI智能STEAM积木平台
871 浏览 0 评论
2698 浏览 2 评论
【youyeetoo X1 windows 开发板体验】+ 影音处理和AI模型移植
2316 浏览 5 评论
I.MX6ULL-飞凌 ElfBoard ELF1板卡- 移植zbar的方法
1717 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
5862 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-4-26 16:20 , Processed in 0.622690 second(s), Total 69, Slave 52 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号