#include #include #define SerMor1 P34 //door #define SerMor2 P35 //hand void delay(short); void MOR_init(void); void Open(void); //開門 void Close(void); //關門 void TouchSW(void); //伸手關開關 void HandHome(void); //手回原點(盒子內) //unsigned int dutytime = 45536; //65536-45536 = 20ms unsigned int ton = 1500; //高電位1.5ms unsigned int toff = 18500; //低電位18.5ms unsigned int temp; //計時器工作用 unsigned char x=30,y=0,C=30; //x:PWM次數 y:選擇馬達 bit O=0; //開門旗標 void timer0_initialize(void) { SerMor1=0; SerMor2=0; EA=0; IE|=0x02; TMOD|=0x01; temp=65536-ton; TH0=temp/256; TL0=temp%256; // TR0=1; EA=1; } void timer0_isr(void) interrupt 1 using 1 //PWM TR0 { if(x