Quote:
Originally Posted by Generalx5
Something like this?
#define Setting_1 ((solenoid1 = 1) && (Solenoid2 = 0) && (solenoid3 = 1) && (solenoid4 = 0) && (solenoid5 = 0) && (solenoid6 = 0));
|
I don't think this is what you want to do. If you want Setting_1 to turn on Solenoid1 and solenoid3, with the others off, you would write the following:
Code:
/* Setting_1 - Turn on solenoids 1&3 only */
#define Setting_1 solenoid1 = 1;Solenoid2 = 0; solenoid3 = 1;solenoid4 = 0; solenoid5 = 0; solenoid6 = 0
This makes it clear you are doing assignments. You could put braces around the assignment statements to make the command look like a single statement to the compiler. This is not needed if you always use braces for the executable statements in if(), while() and for() statements.
Some additional advice for you and others reading this thread:
- Writing code with comments that explain what is intended is one of the best ways to prevent and debug mistakes. Including these comments of what you intend to do when you ask for advice really helps us help you.
- Routine names like Setting_1 are great for examples to illustrate a point, but in your robot code, use names like "Extend_L_R_arms_only"
- In programming there are often dozens of ways to accomplish the task. Often the choice should be made by which will be easiest to understand, debug, and modify as the program develops.