View Single Post
  #14   Spotlight this post!  
Unread 01-12-2006, 14:13
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Auto Mode!!! WHOA...what tha?

Quote:
Originally Posted by teh_pwnerer795
Here is an example of what would happen if you did not restate ur pwm's

NOT DECLARING

if (rc_dig_in01 == 0)
{
pwm01 = 0;
}

(pwm01 would stay at the value 0 when button is pressed. Once its unpressed, the value will stay at 0.)
Unless something else assigns a different value to pwm01, that is correct.
Quote:
Originally Posted by teh_pwnerer795
DECLARING

if (rc_dig_in01 == 0)
{
pwm01 = 0;
}

(When button is pressed value will be 0. When it is unpressed, the value will be 127
Unless something else assigns a different value to pwm01, that is wrong.

You seem to be under the impression that "declaring" a variable works some magic that keeps setting it to a specific value. If you want pwm01 to always be 127 when the button is released, you'll have to do it yourself. Either
Code:
pwm01 = 127;
if (rc_dig_in01 == 0)
{
    pwm01 = 0;
}
or
Code:
if (rc_dig_in01 == 0)
{
    pwm01 = 0;
}
else
{
    pwm01 = 127;
}