#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
uint time,left, right,pwm0,pwm1,pwm2,pwm3;
sbit IN1 = P1^0;
sbit IN2 = P1^1;
sbit IN3 = P1^2;
sbit IN4 = P1^3;
sbit infrared1=P0^5;
sbit infrared2=P0^3;
sbit infrared3=P0^1;
void speed(int left,int rihgt)//该函数的作用是给pwm0,pwm1,pwm2,pwm3赋值
{
if(left>=0)
{
pwm0=left;
pwm1=0;
}
else
{
pwm0=0;
pwm1=0-left;
}
if(rihgt>=0)
{
pwm2=left;
pwm3=0;
}
else
{
pwm2=0;
pwm3=0-left;
}
}
void main()
{
TMOD =0x01;
TH0=(65536-10)/256;
TL0