Skip to content

Instantly share code, notes, and snippets.

@wtfil
Created July 19, 2014 09:49
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 wtfil/6d11259b84053cfd86c7 to your computer and use it in GitHub Desktop.
Save wtfil/6d11259b84053cfd86c7 to your computer and use it in GitHub Desktop.
arduino-motors
#include <Servo.h>
int MOTOR_PIN = 9;
int MIN = 1000;
int MAX = 2000;
Servo motor;
void setup() {
motor.attach(MOTOR_PIN);
}
int ds = 10;
int val = MIN + ds;
void loop() {
if (val >= MAX || val <= MIN) {
ds = -ds;
}
val += ds;
motor.writeMicroseconds(val);
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment