Created
July 19, 2014 09:49
-
-
Save wtfil/6d11259b84053cfd86c7 to your computer and use it in GitHub Desktop.
arduino-motors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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