Skip to content

Instantly share code, notes, and snippets.

@8q
Last active July 9, 2018 17:58
Show Gist options
  • Save 8q/253fdd04378b5a96ceaf43eba347866c to your computer and use it in GitHub Desktop.
Save 8q/253fdd04378b5a96ceaf43eba347866c to your computer and use it in GitHub Desktop.
#include <Servo.h>
#define SERVO_PIN 3
Servo servo;
void setup() {
Serial.begin(9600);
servo.attach(SERVO_PIN);
servo.write(60);
}
void loop() {
if(Serial.available() > 0) {
char c = Serial.read();
switch(c) {
case 'x':
servo.write(100);
Serial.println("off");
delay(1000);
servo.write(60);
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment