Skip to content

Instantly share code, notes, and snippets.

@Morendil
Created June 15, 2014 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Morendil/8bb816fdfdd12c2c36a8 to your computer and use it in GitHub Desktop.
Save Morendil/8bb816fdfdd12c2c36a8 to your computer and use it in GitHub Desktop.
#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