Skip to content

Instantly share code, notes, and snippets.

@ringodin
Created August 29, 2015 14:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ringodin/99e6de007a256f1f2ea0 to your computer and use it in GitHub Desktop.
Save ringodin/99e6de007a256f1f2ea0 to your computer and use it in GitHub Desktop.
#include <Servo.h>
Servo lefty; // create servo object to control a servo
Servo righty; // a maximum of eight servo objects can be created
int leftEye = 13;
int rightEye = 11;
void setup()
{
lefty.attach(9); // attaches the servo on pin 9 to the servo object
righty.attach(7);
pinMode(leftEye, OUTPUT);
pinMode(rightEye, OUTPUT);
}
void loop()
{
lefty.write(180);
righty.write(180);
digitalWrite(leftEye, LOW);
digitalWrite(rightEye, LOW);
delay(1000);
lefty.write(0);
righty.write(0);
digitalWrite(leftEye, HIGH);
digitalWrite(rightEye, HIGH);
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment