Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- Servo myServo; // Create a servo object to control a servo
- int servoPin = 9; // Pin connected to the servo
- void setup() {
- myServo.attach(servoPin); // Attach the servo to the pin
- }
- void loop() {
- // Move the servo to the starting position (0 degrees)
- myServo.write(0);
- delay(1000); // Wait for 1 second
- // Move the servo to the middle position (90 degrees)
- myServo.write(90);
- delay(1000); // Wait for 1 second
- // Move the servo to the end position (180 degrees)
- myServo.write(180);
- delay(1000); // Wait for 1 second
- // Move the servo to the middle position (90 degrees)
- myServo.write(90);
- delay(1000); // Wait for 1 second
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement