View Single Post
  #20   Spotlight this post!  
Unread 17-03-2004, 22:16
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
Re: Help! Programming question with triggers

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

Last edited by KenWittlief : 17-03-2004 at 22:19.