Quote:
|
Originally Posted by AsimC
hmm this is how i originally did it...but it doesnt work. What happens is when i click the trigger, its constantly going forward even when i let go.
Code:
if (p3_sw_trig==1)
{
pwm07=175;
pwm08=175;
}
if (p3_sw_top==1)
{
pwm07=90;
pwm08=90;
}
|
the reason why your motors keep running is because there is no path in your code where you tell them to be = 127 and stop running
the way your code is written if neither switch is closed then the pwm outputs will still be what they were the last time the loop ran, and the time before that... your code leaves them at 175 or 90.
you could put
pwm07=127;
pwm08=127;
above your if statement - have them = 127 by default, then if either switch is closed they will be something else instead
this is a common mistake