Last active
September 27, 2019 14:51
-
-
Save soemarko/536dd186c18da136c311c3b12ad0865e 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> | |
int endstopPin = 7; | |
int val = 0; | |
Servo s; | |
int servoPin = 9; | |
int stowAngle = 30; | |
int deployAngle = 160; | |
char serialIn = ' '; | |
// the setup function runs once when you press reset or power the board | |
void setup() { | |
Serial.begin(115200); | |
while (!Serial) { | |
; // wait for serial port to connect. Needed for native USB port only | |
} | |
Serial.println("Serial ready... send 's' to stow and 'd' to deploy"); | |
pinMode(LED_BUILTIN, OUTPUT); | |
pinMode(endstopPin, INPUT); | |
s.attach(servoPin); | |
s.write(stowAngle); | |
} | |
// the loop function runs over and over again forever | |
void loop() { | |
val = digitalRead(endstopPin); | |
digitalWrite(LED_BUILTIN, val); | |
if (Serial.available() > 0) { | |
serialIn = (char)Serial.read(); | |
if (serialIn == 's') { | |
Serial.println("Stow"); | |
s.write(deployAngle); | |
} | |
else if (serialIn == 'd') { | |
Serial.println("Deploy"); | |
s.write(deployAngle); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment