hey all. i posted a question, but I am entirely unable to find it no matter the search I do. Just converted to google chrome so that might be the matter, I don't really know. I would like to make a servo go in these steps. 60 degrees, stop, 45 degrees, stop, 180 degrees, stop (DELAY) for a minute or 2. The "Arduino example" uses a "for " loop (Artduino examples/servo). Can you stack "for" loops? (per say the example) I am rather limited right now do to delivery dates/supply chains......
I have learned how to change the degrees, I have learned how to change the time it takes to get to the degree. But I can't find anything in tutorials that has statements for turn 60 degrees, stop, turn 45 degrees, stop, turn 180 degrees, DELAY for a couple minutes. And repeat.......Without the ability to compose it at the moment, I am guessing an "else" statement would be required? turn 60 degrees "else"turn 45 degrees......????? Thanks, Fred
Code:
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15 ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15 ms for the servo to reach the position
}
}