Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- struct myServo {
- Servo servo;
- int pos = 0;
- void attach(int pin) {
- servo.attach(pin, 500, 2500);
- }
- void swipe() {
- for (pos = 0; pos <= 180; pos += 1) {
- servo.write(pos);
- delay(15);
- }
- for (pos = 180; pos >= 0; pos -= 1) {
- servo.write(pos);
- delay(15);
- }
- }
- void angle(int angle) {
- servo.write(angle);
- }
- };
- struct myServo servo1;
- void setup()
- {
- servo1.attach(9);
- }
- void loop()
- {
- servo1.swipe();
- servo1.angle(50);
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement