Created
November 3, 2021 07:09
-
-
Save billykwok/8f126a8ebcbccfb38f08ad2d9ee50b59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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