Skip to content

Instantly share code, notes, and snippets.

@billykwok
Created November 3, 2021 07:09
Show Gist options
  • Save billykwok/8f126a8ebcbccfb38f08ad2d9ee50b59 to your computer and use it in GitHub Desktop.
Save billykwok/8f126a8ebcbccfb38f08ad2d9ee50b59 to your computer and use it in GitHub Desktop.
#include <Servo.h>
#define PIN_SERVO_ARM 10
#define PIN_SERVO_STAGE 9
#define ANGLE_COLLAPSE 105
#define ANGLE_EXPAND 0
Servo servoArm;
Servo servoStage;
void setup() {
Serial.begin(9600);
servoArm.attach(PIN_SERVO_ARM);
servoStage.attach(PIN_SERVO_STAGE);
}
void loop() {
servoStage.write(random(0, 2) >= 1 ? 120 : 60);
delay(200);
for (int pos = ANGLE_COLLAPSE; pos >= ANGLE_EXPAND; --pos) {
servoArm.write(pos);
delay(15);
}
delay(1000);
for (int pos = ANGLE_EXPAND; pos <= ANGLE_COLLAPSE; ++pos) {
servoArm.write(pos);
delay(15);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment