I am writing a program where the beginning statement is a conditional statement to initiate a loop...is there a code that will only check this and not return to it again...?
In other words, is there a way to tell arduino to initialize a program based on an input but then change that input in the program itslef?
another possibility is:
Is there a way to have a conditional statement for an input that will last a certain amount of time?
If I read the question correctly, sure. For example:
int flag1;
void setup() {
flag1 = InitializeSensor1(); // We assume the function returns an int
if (flag1 != 0) {
flag1 = 100; // Where 100 might mean something in loop()
} else {
flag1 = 0; // Perhaps the sensor is bad
}
// rest of setup()
}
The call to InitilizeSensor1() sets the value of flag1 to some value that makes sense for the program or 0 if the sensor is not working. Now you can use flag1 in loop() is the sensor is "good" or bypass it if it's "bad".
Thank you for the quick response, I guess I should have given some context...
I have four input switches for motor control, I want the program to start if one of them is detected as HIGH if not nothing should happen...so after setting the setup() how would I call it in loop() ?