Advertisement
skogge

toa spolare

Jan 26th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. /*toa spolare, arm 1 (servoA) viker ut och servoB spolar, sen tillbaks till start position */
  2.  
  3. #include  <Servo.h>
  4. Servo servoA, servoB;
  5. int isObstaclePin = 2;  // This is our input pin
  6. int isObstacle = HIGH;  // HIGH MEANS NO OBSTACLE
  7.  
  8. void setup() {
  9.   servoA.attach(9);
  10.   servoB.attach(10);
  11.   pinMode(isObstaclePin, INPUT);
  12.   Serial.begin(9600);
  13. }
  14.  
  15. void loop() {
  16.   isObstacle = digitalRead(isObstaclePin);
  17.   if (isObstacle == LOW)
  18.   {
  19.     servoA.write(90); //rod1
  20.     delay(1000);
  21.     servoB.write(90); //flush
  22.     delay(2000);
  23.     servoB.write(0);  //return flush
  24.     delay(1000);
  25.     servoA.write(0);  //return rod to start
  26.  
  27.   }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement