Ground Pounder,
Here is a draft of what I think the code would look like.
- CAVEAT #1 - I did not compile it, and you'll need to double-check that the for loop limits and ++/-- are correct.
- CAVEAT #2 - I did not attempt to move the servos simultaneously. In order to do this effectively, we'll need to really understand the gearing for the wiper. Does it really have to move simultaneously? Because they aren't geared the same, one servo may appear to stutter when it moves. (This is due to the fact that each will move different "actual" degrees in each 5ms step.)
//
// 2 servos operate as depicted (without plunger) in https://www.youtube.com/watch?v=yhlfb8BLzMk
//
#include <Servo.h>
Servo wiper; // create servo object to control a servo
Servo turnstile; // a maximum of eight servo objects can be created
const int MIN_WIPER_DEGREES = 0;
const int MAX_WIPER_DEGREES = 25; // actually geared to 338*
const int MID_WIPER_DEGREES = (MIN_WIPER_DEGREES + MAX_WIPER_DEGREES)/2;
const int MIN_TURNSTILE_DEGREES = 0;
const int MAX_TURNSTILE_DEGREES = 180;
const int MID_TURNSTILE_DEGREES = (MIN_TURNSTILE_DEGREES + MAX_TURNSTILE_DEGREES)/2;
const int STEP_DELAY = 5; // ms
void setup()
{
wiper.attach(14); // attaches the servo on pin A0 to the servo object
turnstile.attach(15); // attaches the servo on pin A1 to the servo object
//
// start in position 1 -- wiper in max position, turnstile in max position (:28 in video)
//
wiper.Write(MAX_WIPER_DEGREES);
turnstile.Write(MAX_TURNSTILE_DEGREES);
delay(100); // wait to get there
}
void loop()
{
int degree; // for loop counter
//
// move to position 2 -- wiper in min position, turnstile in max position (:35 in video)
//
for (degree = MAX_WIPER_DEGREES; degree >= MIN_WIPER_DEGREES; degree--)
{
wiper.write(degree);
delay(STEP_DELAY);
}
//
// move to position 3 -- wiper in min position, turnstile at mid-point (:37 in video)
//
for(degree = MAX_TURNSTILE_DEGREES; degree >= MID_TURNSTILE_DEGREES; degree--)
{
turnstile.write(degree);
delay(STEP_DELAY);
}
//
// do something here? here is where the plunger acts
//
//
// move to position 4 -- wiper in min position, turnstile at min position (:38 in video)
//
for(degree = MID_TURNSTILE_DEGREES; degree >= MIN_TURNSTILE_DEGREES; degree--)
{
turnstile.write(degree);
delay(STEP_DELAY);
}
//
// move to position 5 -- wiper at max position, turnstile at min position (:45 in video)
//
for (degree = MIN_WIPER_DEGREES; degree <= MAX_WIPER_DEGREES; degree++)
{
wiper.write(degree);
delay(STEP_DELAY);
}
//
// move to position 6 -- wiper at max position, turnstile at mid-point (:47 in video)
//
for(degree = MIN_TURNSTILE_DEGREES; degree <= MID_TURNSTILE_DEGREES; degree++)
{
turnstile.write(degree);
delay(STEP_DELAY);
}
//
// move back to position 1 -- wiper at max position, turnstile at max position (:53 in video)
//
for(degree = MID_TURNSTILE_DEGREES; degree <= MAX_TURNSTILE_DEGREES; degree++)
{
turnstile.write(degree);
delay(STEP_DELAY);
}
// repeat...
}