Skip to content

Instantly share code, notes, and snippets.

@proudlygeek
Created April 26, 2015 21:47
Show Gist options
  • Select an option

  • Save proudlygeek/b409253fcf5eef0b19b2 to your computer and use it in GitHub Desktop.

Select an option

Save proudlygeek/b409253fcf5eef0b19b2 to your computer and use it in GitHub Desktop.
Arduino Servo basic example
#include <Servo.h>
Servo myServo;
int const potPin = A0;
int potVal;
int angle;
void setup() {
myServo.attach(9);
Serial.begin(9600);
}
void loop() {
potVal = analogRead(potPin);
Serial.print("potVal: ");
Serial.print(potVal);
angle = map(potVal, 0, 1023, 0, 179);
Serial.print(", angle: ");
Serial.println(angle);
myServo.write(angle);
delay(15);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment