Created
June 15, 2014 13:32
-
-
Save Morendil/8bb816fdfdd12c2c36a8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
Servo gripper; | |
Servo arm; | |
int pos = 120; | |
int target = pos; | |
void setup() | |
{ | |
Serial.begin(115200); | |
gripper.attach(9); | |
gripper.write(pos); | |
arm.attach(8); | |
arm.write(90); | |
} | |
void loop() | |
{ | |
Servo* output = &arm; | |
if (Serial.available() > 0) { | |
char which = Serial.read(); | |
Serial.println(which); | |
if (which == 'a' || which == 'A') { | |
output = &arm; | |
} | |
if (which == 'g' || which == 'G') { | |
output = &gripper; | |
} | |
target = Serial.parseInt(); | |
Serial.println(target); | |
output->write(target); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment