Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <Servo.h>
  2.  
  3. Servo myservo;
  4.  
  5. const int servoPin = 9;
  6. const int buttonPin = 12;
  7. const int ledPin = 13;
  8.  
  9. void setup() {
  10. myservo.attach(servoPin);
  11. pinMode(buttonPin, INPUT);
  12. digitalWrite(buttonPin, HIGH);
  13. pinMode(ledPin, OUTPUT);
  14. digitalWrite(ledPin, LOW);
  15. myservo.write(180);
  16. delay(1000);
  17. myservo.detach();
  18. }
  19.  
  20. void loop() {
  21. int buttonVal = digitalRead(buttonPin);
  22. if(buttonVal == LOW) {
  23. myservo.attach(servoPin);
  24. myservo.write(30);
  25. delay(575);
  26. myservo.write(180);
  27. delay(1500);
  28. myservo.detach();
  29. delay(5000);
  30. }
  31. delay(13);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement