diff options
Diffstat (limited to 'project/project.ino')
-rw-r--r-- | project/project.ino | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/project/project.ino b/project/project.ino new file mode 100644 index 0000000..d613756 --- /dev/null +++ b/project/project.ino @@ -0,0 +1,22 @@ +#include <Servo.h> + +Servo myservo; + +void setup() { + myservo.attach(0); // attach to pin 0 + analogReadResolution(8); +} + +void loop() { + if (analogRead(A0) > 180) { + for (int pos = 180; pos >= 0; pos -= 5) { // goes from 180 degrees to 0 degrees + myservo.write(pos); // tell servo to go to position in variable 'pos' + delay(15); // waits 15ms for the servo to reach the position + } + for (int pos = 0; pos <= 180; pos += 5) { // goes from 0 degrees to 180 degrees + // in steps of 1 degree + myservo.write(pos); // tell servo to go to position in variable 'pos' + delay(15); // waits 15ms for the servo to reach the position + } + } +} |