-
1Run a Program
#include
Servo myservo; // providing a name
int angle = 0; // variable to store the servo position
void setup() {
myservo.attach(2); // attaches the servo on pin 2 to the servo object
}void loop() {
for (angle = 0; angle <= 0 1 180 180; angle +="1)" { goes from degrees to degrees, in steps of degree myservo.write(angle); tell servo go position variable 'angle' delay(15); waits 15ms for the reach } (angle="180;">= 0; angle -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(angle);
delay(15); // waits 15ms for the servo to reach the position
}
}
</=>
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.