Guest User

Untitled

a guest
Oct 14th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <Servo.h>
  2.  
  3. int pinServo = 11;
  4. int pinSwitch = 10;
  5. boolean a180=true;
  6.  
  7. Servo myservo1;
  8. Servo myservo2;
  9.  
  10. void setup()
  11. {  
  12.   myservo1.attach(11);
  13.   pinMode(pinSwitch,INPUT);
  14. }
  15.  
  16. void loop()
  17. {
  18.   if (a180 == true){
  19.     myservo1.write(180);
  20.     delay(2000);
  21.   }else{
  22.     myservo1.write(0);
  23.     delay(2000);
  24.   }
  25.  
  26.   if (digitalRead(pinSwitch) == HIGH){
  27.     if (a180 == true){
  28.       a180 = false;
  29.     }else{
  30.       a180=true;
  31.     }
  32.   }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment