Commit e41b53f9 authored by rajudev's avatar rajudev

Added a few test codes

parent 53b36a55
Pipeline #874 skipped
#include <Servo.h>
Servo servo1; // create servo object to control a servo
Servo servo2;
Servo servo3;
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
servo1.attach(0); // attaches the servo on pin 9 to the servo object
servo2.attach(1);
servo3.attach(2);
}
void loop() {
for (pos = 0; pos <= 35; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
servo1.write(pos);
servo2.write(pos); // tell servo to go to position in variable 'pos'
servo3.write(pos);
delay(30); // waits 15ms for the servo to reach the position
}
for (pos = 35; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
servo1.write(pos); // tell servo to go to position in variable 'pos'
servo2.write(pos);
servo3.write(pos);
delay(30); // waits 15ms for the servo to reach the position
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment