Quote:
|
Originally Posted by rbayer
A few things I saw after glancing at it:
Code:
if (armcounter = 15) //will raise arm.
pwm06=0;
else
armcounter++;
pwm06=255;
sould be
Code:
if (armcounter == 15) //will raise arm.
pwm06=0;
else {
armcounter++;
pwm06=255;
}
It is VERY rare that you'll actually want to use a single = in an if, so watch out for that, and also be careful with your curly braces.
That said, I believe the code in its original form should have printf'd 15 over and over and over. Was it doing that, or just not printing anything?
|
remember that you need to add the curly braces, not just change the equals sign to a double-equals. w/o the braces, the code is equivalent to this:
Code:
if (armcounter == 15) //will raise arm.
pwm06=0;
else {
armcounter++;
}
pwm06=255;
note how pwm06 will always end up as 255, no matter what the value is.
you said that the "motors weren't stopping" - of course they aren't: 0 is full reverse, 255 is full forward. if you want a motor to stop, set the PWM to 127.