这个小车为什么只能朝一边转?
void turnright()
{
mot1=0;
mot2=15;
IN11=0;
IN12=0;
IN13=0;
IN14=1;
IN21=0;
IN22=0;
IN23=1;
IN24=0;
}
void turnleft()
{
mot1=15;
mot2=0;
IN11=0;
IN12=1;
IN13=0;
IN14=0;
IN21=1;
IN22=0;
IN23=0;
IN24=0;
}
void PWM_right_turn()
{
unsigned char t=0;
t++;
t%=100;
if(t<mot2)
{
ENB1=1;ENB2=1;
}
else
{
ENB1=0;ENB2=0;
}
}
void PWM_left_turn()
{
unsigned char t=0;
t++;
t%=100;
if(t<mot1)
{
ENA1=1;ENA2=1;
}
else
{
ENA1=0;ENA2=0;
}
}
#include <REGX52.H>
#include "Delay.h"
#include "Time0.h"
#include "Trolley.h"
unsigned char counter,compare;
void main()
{
Timer0Init();
compare=50;
turnright();
while(1)
{
}
}
void Timer0_Routine() interrupt 1
{
TL0 = 0xA4;
TH0 = 0xFF;
PWM_right_turn();
PWM_left_turn();
}