Created
December 11, 2014 05:34
-
-
Save jimmyli97/41b9d23f61e09fd2a2fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Recall that Robotc stores the list of motors as the following: | |
typedef enum tMotor { | |
leftMotor = 0, | |
rightMotor = 7, | |
centerMotor = 1, | |
} tMotor; | |
//We can keep track of the number of motors using a constant that is updated by hand | |
#define NUM_MOTORS 3 | |
//We can then create an array that we loop through to get all motors | |
tMotor motorList[NUM_MOTORS]; | |
//We can then store tMotors into this array in the initialization function. | |
motorList[0] = leftMotor; | |
... | |
//When we want to loop through all motors, we loop through with NUM_MOTORS as the limit | |
for (int i=0; i<NUM_MOTORS; i++) { | |
tMotor currentMotor = motorList[i]; | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment