Hi! we need your help again... we have three servomotors turning of 90° after having pressed the corresponding button. We need to make these servos move cyclically in a lapse of time. (i.e. for 1 to 30 seconds I can open ONLY the first servo, 31 to 60 seconds i can open only the second one and 61 to 90 secs only the third one.)
The code we wrote so far doesn't include the time function: all the buttons can work almost together (but we have to consider the time taken by servos to move).
We have three cases:
- botton A is pressed --> servo A moves and LED A turns on
- button B is pressed --> servo B moves and LED B turns on
- button C is pressed --> servo C moves and LED C turns on
we tried to put another condition, something like that:
void loop() {
for (time = 0; time < 90000; time++) {
if (time == 90000) time = 0;
if (time >= 0 && time < 30000) lapse = 1;
if (time >= 30000 && time < 60000) lapse = 2;
if (time >= 60000 && time < 90000) lapse = 3;
if (buttonA == LOW && lapse == 1) move servo A...
if (button B == LOW && lapse == 2) move servo B...
if (button C == LOW && lapse == 3) move servo C...
....
}
But it doesn't seem to work... Maybe it's wrong...
Does anyone of you know how we can write it with code?
Thank you!!!