Last active
December 19, 2015 18:18
-
-
Save boxalljohn/5997600 to your computer and use it in GitHub Desktop.
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
| // Example 3.3 – servo examination | |
| #include <Servo.h> | |
| Servo myservo; // create servo object to control a servo | |
| int pos = 0; // variable to store the servo position | |
| int del = 100; // delay in micoseconds | |
| void setup() | |
| { | |
| Serial.begin(9600); | |
| myservo.attach(9); // attaches the servo on pin 9 to the servo object | |
| } | |
| void loop() | |
| { | |
| for (int loopy = 0; loopy<=3; loopy++) | |
| { | |
| for (pos = 180; pos >=0; pos--) // from left to right with Hextronik HXT900 | |
| { | |
| myservo.write(pos); | |
| delay(del); | |
| } | |
| delay(1000); | |
| } | |
| for (int loopy = 0; loopy<=3; loopy++) | |
| { | |
| myservo.write(180); | |
| delay (1000); | |
| myservo.write(90); | |
| delay (1000); | |
| myservo.write(0); | |
| delay (3000); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment