ÄÚÈÝ·¢²¼¸üÐÂʱ¼ä : 2024/11/20 14:41:58ÐÇÆÚÒ» ÏÂÃæÊÇÎÄÕµÄÈ«²¿ÄÚÈÝÇëÈÏÕæÔĶÁ¡£
Áù¡¢½áÂÛ
¾Êµ¼ù±íÃ÷£¬±¾ÎÄËùÉè¼ÆÖÆ×÷µÄºìÍâÏßÒ£¿ØС³µÔËÐÐÎȶ¨¡¢Ò£¿ØÁéÃô¡¢Õ¼ÓÃϵͳӲ¼þ×ÊÔ´ÉÙ¡£ÇÒÔÚ²»¸Ä±äÓ²¼þµç·£¬½öͨ¹ýÈí¼þ±à³ÌС³µ¾Í¿ÉÒÔʵÏֶദÕÏ°Îï¼ì²â¡¢±¨¾¯µÈ¹¦ÄÜ¡£
ÓÉÓÚÄ¿Ç°µÄÒ£¿Ø×°Öôó¶à¶ÔijһÉ豸½øÐе¥¶À¿ØÖÆ£¬¶øÔÚ±¾Éè¼ÆÖеĺìÍâÒ£¿Øµç·Éè¼ÆÁ˶à¸ö¿ØÖÆ°´¼ü£¬¿ÉÒÔ¶Ô²»Í¬µÄÉ豸£¬Ò²¿ÉÒÔ¶ÔͬһÉ豸µÄ¶à¸ö¹¦ÄܽøÐв»Í¬µÄ¿ØÖÆ¡£»ù±¾·ûºÏ¼¼ÊõÒªÇó¡£
±¾ÏëÔڵײ¿Ôö¼ÓѼ£¹¦ÄÜ£¬µ«³öÓÚ´«¸ÐÆ÷ÊýÁ¿ÓÐÏÞ£¬µ×²¿Ö»Ê£ÏÂÁ½¸öºìÍâ´«¸ÐÆ÷£¬ÊµÏÖѼ£À§ÄÑ¡£Òò´Ë¸ÄΪ¼ì²éÊÇ·ñÀëµØµÄ¹¦ÄÜÄ£¿é¡£
µ«ÊDZ¾Ò£¿Øµç·ҲÓв»ÍêÉƵĵط½,ËüÖ»Äܵ¥Í¨µÀʵÏÖ¶Ô¶à¸öÉ豸µÄ¿ØÖÆ,¼´Ëü²»ÄÜͬʱ¿ØÖÆÁ½¸ö»òÕßÁ½¸öÒÔÉϵÄÉ豸¡£
ÔÚÉè¼Æ¹ý³ÌÖУ¬Í¨¹ý´óÁ¿µÄ²éÔÄ×ÊÁÏ£¬ÈÏÕæÑо¿½Ì²Ä£¬¶Ôµ¥Æ¬»úÓÐÁ˸üΪÉî¿ÌµÄÀí½â£¬ÔÚÉè¼ÆÈí¼þʱ£¬Ðë×ÐϸµÄ·ÖÎöÓ²¼þµç·£¬»³ö³ÌÐòÁ÷³Ìͼ£¬ÅàÑøÁËÎÒµÄÄÍÐԺͿ̿à×êÑеľ«Éñ¡£
¡¾²Î¿¼ÎÄÏס¿
1¡¢¡¶ÊµÀý½â¶Á51µ¥Æ¬»úÍêȫѧϰÓëÓ¦Óã¨Åä½ÌѧÊÓƵ£©¡·£¬ÑîÐÀ±àÖø£¬µç×Ó¹¤Òµ³ö°æÉç¡£
2¡¢¡¶°®Éϵ¥Æ¬»ú¡·£¬¶ÅÑóÖø£¬ÈËÃñÓʵç³ö°æÉç¡£
3¡¢¡¶È«¹ú´óѧÉúµç×ÓÉè¼Æ¾ºÈü½Ì³Ì--»ùÓÚtiÆ÷¼þÉè¼Æ·½·¨¡·£¬»Æ´º¸ùµÈÖø£¬µç×Ó¹¤Òµ³ö°æÉç¡£
9
¡¾¸½Â¼¡¿
Ô´³ÌÐò
#include
unsigned char IrValue[6];
unsigned char jd1,jd2,m1,m2,count,Time,i,value,flag;
sbit IRIN=P3^2; sbit pwm1=P2^0; sbit pwm2=P2^1;
sbit left1=P2^2; sbit left2=P2^3; sbit right1=P2^5; sbit right2=P2^4;
sbit led=P2^6; sbit person=P2^7;
sbit xia1=P1^2; sbit xia2=P1^0; sbit qian1=P1^1; sbit qian2=P1^3; sbit hou1=P1^4; sbit hou2=P1^5;
void IrInit();
void DelayMs(unsigned int ); void Timer0_Init(); void go(); void back(); void turnleft(); void turnleft1(); void turnright(); void turnright1(); void add(); void pluse(); void yaokong(); void bizhang(); void stop();
10
void stop1(); void main() {
pwm1=0; pwm2=0; count=0; led=1;
jd1=85;//ÓÒÂÖËٶȳõʼ»¯È¡Öµ·¶Î§0~200 jd2=70;//×óÂÖËٶȳõʼ»¯È¡Öµ·¶Î§0~200
IrInit();
Timer0_Init(); left1=0; left2=0; right1=0; right2=0;
qian1=1; qian2=1; //xia1=0; //xia2=0; hou1=1; hou2=1; flag=0; //preson=1; while(1) { while(flag==1)//ÊÖ¶¯Ò£¿Ø { if ((xia1==1)|(xia2==1)) stop(); else if((xia1==0)&(xia2==0)) yaokong(); } while (flag==2) //Ìùǽ×ß { if ((xia1==1)&(xia2==1)) stop(); else { if ((hou1==1)&(hou2==1)) stop(); else if ((hou1==0)&(hou2==1)&((qian1==1)|(qian2==1))) {go();} else if ((hou1==0)&(hou2==1)&((qian1==0)&(qian2==0))) {turnright();DelayMs(5000);} else if ((hou1==1)&(hou2==0)&((qian1==1)|(qian2==1))) {go();}
11
else if ((hou1==1)&(hou2==0)&((qian1==0)&(qian2==0))) {turnleft();DelayMs(5000);} } }
while (flag==3){ if ((xia1==1)&(xia2==1)) stop(); else bizhang();}//±ÜÕÏ while (flag==4) { if ((xia1==1)&(xia2==1)) stop(); else { if(person==1) bizhang(); else if(person==0) { stop(); } } } }}
void Timer0_Init() //º¯Êý¹¦ÄÜ£º¶¨Ê±Æ÷³õʼ»¯,ÿ1usÖ´ÐÐÒ»´Î { TMOD=0x01; TH0=0xff;//65436/256 TL0=0x9c;//65436%6 TR0=1; EA =1; //´ò¿ª×ÜÖÐ¶Ï ET0=1; //´ò¿ª¶¨Ê±Æ÷0ÖÐ¶Ï TR0=1; //Æô¶¯¶¨Ê±Æ÷0 }
void Timer0_Int() interrupt 1//ÖжϳÌÐò {
TH0=0xff; TL0=0x9c;
m1=count; m2=count;
if(m1 if(m2 12 count%=200; //20mÃëÐèÒªÊý200´Î } void yaokong() { switch(value) { case 0x15:stop();break; //°´¼ü case 0x40:go();break; } void go() { led=~led; left1=0; left2=1; right1=0; right2=1; //value=0; } void stop() { led=~led; left1=0; left2=0; right1=0; right2=0; //value=0; } void back() { led=~led; left1=1; left2=0; right1=1; right2=0; //value=0; } case 0x19:back();break; case 0x07:turnleft();break; case 0x09:turnright();break; case 0x1c:stop1();break; case 0x08:turnleft1();break; case 0x5a:turnright1();break; default:break; } 13