#define MRR 0 // L293D right motor control lead #define MRB 1 // L293D right motor control lead #define MLR 3 // L293D left motor control lead #define MLB 2 // L293D left motor control lead #define ITV 10 // timer interrupt interval, in ms, smaller the value gives better IR reception! stop_all() { pinhigh(MRR); pinhigh(MRB); pinhigh(MLR); pinhigh(MLB); } drive(ml, mr, dly) // use the polarities of mr and ml to control the turning directions of motors // 1 = forward // -1 = backward // 0 = stop // using PWM method to control motor running speed { if(ml > 0) { pinlow(MLB); pinhigh(MLR); } else if(ml < 0) { pinhigh(MLB); pinlow(MLR); } if(mr > 0) { pinlow(MRR); pinhigh(MRB); } else if(mr < 0) { pinhigh(MRR); pinlow(MRB); } delay(dly); // let motors stay ON for 'dly' ms stop_all(); // stops ALL delay(ITV - dly); // let motors stay OFF for 'ITV-dly' ms }