Skip to content

Instantly share code, notes, and snippets.

@Mango-kid
Created November 26, 2013 19:32
Show Gist options
  • Save Mango-kid/7664660 to your computer and use it in GitHub Desktop.
Save Mango-kid/7664660 to your computer and use it in GitHub Desktop.
This program will actuate a servo motor back and forth from 0 to 180 degrees
/* This program will actuate a servo motor back and forth from 0 to 180 degrees
*/
#include <Servo.h>
// define the servo object and the angle variable
Servo servo1;
int angle1 = 0;
void setup() {
servo1.attach(9);
}
void loop() {
// increment the servo through 180 degrees
for(angle1 = 0; angle1 < 180; angle1 += 1) {
// update the angle and wait a little
servo1.write(angle1);
delay(15);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment