Skip to content

Instantly share code, notes, and snippets.

@jacobrosenthal
Created December 7, 2014 14:22
Show Gist options
  • Save jacobrosenthal/67035493e0e3bd708fd4 to your computer and use it in GitHub Desktop.
Save jacobrosenthal/67035493e0e3bd708fd4 to your computer and use it in GitHub Desktop.
Light Blue Bean Slider Control 2 Servos
#define LEFT 0
#define RIGHT 2
int leftServoPin = 0;
int rightServoPin = 1;
void setup(){
pinMode(leftServoPin, OUTPUT);
pinMode(rightServoPin, OUTPUT);
}
void loop(){
// Get any serial input from sandbox IOS app
char buffer[64];
size_t length = 64;
length = Serial.readBytes(buffer, length);
if ( length > 0 )
{
for (int i = 0; i < length - 1; i += 2 )
{
if ( buffer[i] == LEFT )
{
analogWrite(leftServoPin, buffer[i+1]);
}
else if ( buffer[i] == RIGHT )
{
analogWrite(rightServoPin, buffer[i+1]);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment