View Single Post
  #5   Spotlight this post!  
Unread 14-01-2008, 00:56
Gamer930's Avatar
Gamer930 Gamer930 is offline
Team 930 and 171 Alumni
AKA: Justin
no team
Team Role: Alumni
 
Join Date: Mar 2002
Rookie Year: 2002
Location: New Berlin, WI
Posts: 388
Gamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to behold
Re: Controller Speed programming

Quote:
Originally Posted by JohnC View Post
This code should work copied and pasted (assuming you want your Port 1 joystick to control pwm01):
Code:
if(p1_y > 127) {
  pwm01 = 150;
}

if(p1_y > 200) {
  pwm01 = p1_y;
}
Just a word of wisdom: If you are doing consecutive if statements comparing the same variable to numbers it is almost always better to use multiple ElseIf.

Why? With If statements the processor has to check each condition to see if it is true or false. In an if/if else statement once condition is true it skips all other. This will allow you programs to execute faster.

Won't notice much of a difference in this programming but if you start getting longer If statements with huge conditions you will start noticing the speed difference
__________________
2010 to Present, Scorekeeper/Field Power Volunteer for FRC/FTC/FLL
2005 - 2010, Team 171 College Mentor
2002 - 2005, Team 930 Student