Created
November 17, 2014 23:59
-
-
Save nortbotics/e187358e3757d331c452 to your computer and use it in GitHub Desktop.
Pan & Tilt Example Using DFRobot 270 degree Servos
This file contains hidden or 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
| // NORTBOTICS | |
| // Pan & Tilt Example Using DFRobot 270 degree Servos | |
| // CC BY SA 4.0 (Use as you wish, but share-alike and give credit) | |
| #include <VarSpeedServo.h> | |
| VarSpeedServo myservo1; | |
| VarSpeedServo myservo2; | |
| const int servoPin1 = 10; // the digital pin used for the servo | |
| const int servoPin2 = 11; // the digital pin used for the servo | |
| // sequences are defined as an array of points in the sequence | |
| // each point has a position from 0 - 270, and a speed to get to that position | |
| servoSequencePoint slow[] = {{0,30},{90,30},{180,30},{270,30}}; // go to position 0 at speed of 30, position 90 speed 30, position 180, speed 30, etc. | |
| // the setup routine runs once when you press reset: | |
| void setup() { | |
| myservo1.attach(servoPin1); | |
| myservo2.attach(servoPin2); | |
| } | |
| // the loop routine runs over and over again forever: | |
| void loop() { | |
| myservo1.sequencePlay(slow, 4); | |
| myservo2.sequencePlay(slow, 4); | |
| delay(2); // delay in between reads for analogin stability | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment