Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Dec/Inc Pendulum Sweep by Sean
- */
- #include <VarSpeedServo.h>
- VarSpeedServo myservo; // create servo object to control a servo
- // a maximum of eight servo objects can be created
- const int servoPin = 9; // the digital pin used for the servo
- int val1=0; // variable to read the value from the analog pin
- int val2=180; // variable to read the value from the analog pin
- int x;
- void setup() {
- myservo.attach(servoPin); // attaches the servo on pin 9 to the servo object
- //myservo.write(90,80,true); // set the intial position of the servo, as fast as possible, wait until done
- Serial.begin(9600);
- }
- void loop() {
- for (int x=0; x<180; x+=2) {
- val1 +=2;
- myservo.write(val1,80,true); // you can adjust the 80 speed
- Serial.println ("val1=");
- Serial.println (val1);
- myservo.write(val2,80,true); // you can adjust the 80 speed
- val2 -=2;
- Serial.println ("val2=");
- Serial.println (val2);
- Serial.println ("val1=");
- Serial.println (val1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement