Electric Trolley Program

Source: Internet
Author: User

1#include <reg52. H>2 //#include "infrared. H"3#include <intrins.h>4 //extern unsigned char flag,model,gears,c,rev,set_temperature;5 #defineUchar unsigned char6 voidDelay (unsignedintx);//x*0.14ms7Sbit IN1 = p2^0;//Motor Direction8Sbit IN2 = p2^1;//Motor Direction9Sbit IN3 = p2^2;//Motor DirectionTenSbit IN4 = p2^3;//Motor Direction One   ASbit IRIN = p3^2;//Infrared receiver Data cable -Sbit v = p2^0; -Uchar ircom[7]; the voidIr_in () Interrupt0 using 0 - { -UnsignedCharj,k,n=0; -   +EX0 =0;//turn off external interrupts to prevent recurrence of interrupts into the detection boot code phase (9MS low 4.5ms High) -Delay the); +      if(irin==1)  A{EX0 =1;  at        return; -       }  -                            //confirm that the IR signal appears -    while(! IRIN)//when the IR becomes high, the leading low signal of 9MS is skipped.  -{Delay (1);} -  in   for(j=0;j<4; j + +)//collect four sets of data -  {  to        for(k=0;k<8; k++)//8 bits per set of data +       { -             while(IRIN)//when the IR becomes low, skip the 4.5ms boot high level signal.  the{Delay (1);} *              while(! IRIN)//when IR changes to high level ${Delay (1);}Panax Notoginseng               while(IRIN) -               { theDelay1); +n++;  A                 if(n>= -) the                      {  +ex0=1; -                          return; $                      }                   $               }                                         -IRCOM[J]=IRCOM[J] >>1;  -              if(n>=8) {Ircom[j] = Ircom[j] |0x80;}  then=0; -}//End for KWuyi}//End for J the     -    if(ircom[2]!=~ircom[3])//determine if there is no error (the responsibility to give up no key code) Wu{ex0=1; -      return;  About    } $    Switch(ircom[2]) -{//display the character keys on the remote control -            Case 0x45: Break;//Press switch on key to display the first feature item of the function array -              Case 0x46: Break;//function to select the 1602 display function A              Case 0x47: Break;//quiet for controlling the sound or not +              Case 0x44://back thein1=0; -In2=1; $in3=1; thein4=0; the                  Break;  the              Case 0x40://forward thein1=1; -In2=0; inin3=0; thein4=1; the                  Break;  About              Case 0x43://Braking thein1=0; theIn2=0; thein3=0; +in4=0; -                  Break;  the              Case 0x07: Break;//eq for return key, return back to first functionBayi             Case 0x15: Break; the               Case 0x09: Break; the               Case 0x16: Break; -              Case 0x19: Break; -              Case 0x0d: Break; the              Case 0x0c: Break; the              Case 0x18: Break; the              Case 0x5e: Break; the              Case 0x08: Break; -              Case 0x1c: Break; the              Case 0x5a: Break; the              Case 0x42: Break; the              Case 0x52: Break;94              Case 0x4a: Break; the          } theEX0 =1; the          98 } About  - /**********************************************************/101 voidDelay (unsignedintX//x*0.14ms102 {103UnsignedChari;104    while(x--) the  {106    for(i =0; i< -; i++) {}107  }108 }109  the voidIntn_0 ()//IR Interrupt Initialization111 { theirin=1;//I/O port initialization113IE |=0x81;//allow total interrupt interrupt to enable INT0 external interrupt theTCON |=0x01;//trigger mode is pulse negative edge trigger theip=0x20; the }117 118 voidMain ()119 { -     121 intn_0 ();122     123      while(1);124      the}

Electric Trolley Program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.