|
Re: Controller Speed programming
Quote:
Originally Posted by JohnC
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
|