It really isn't all that far from being C.
Why don't you make a start, and get back to us when you get stuck?
Don't forget to use
tags when you post it.
Some clues:
These numbers int stateDelay[] = {0, 20, 15, 10};
are found in places like this
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(20); // waits 15ms for the servo to reach the position
}
in your code.