View Single Post
  #10   Spotlight this post!  
Unread 16-02-2006, 09:30
Mark Pierce Mark Pierce is offline
Registered User
FRC #0085 (B. O. B.)
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 1999
Location: Zeeland, MI
Posts: 239
Mark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant future
Re: Control Problems

I'd also move the pwm assignment to after the if statement. Otherwise, there will be an additional cycle delay in your response, since the pwm will reflect the old value from the if statement.

The my_y value could be defined as an unsigned character (8 bits) instead of int. It's not essential, but it is good practice to match variable types.

Code:
unsigned char my_y;

if (p3_sw_trig==1) {
    my_y = p2_y;
}
else {
    my_y = 127;
}
pwm02 = my_y;