Advertisement
Guest User

Yuneec gimbal startup

a guest
Feb 27th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include <Servo.h>
  2.  
  3. Servo myservo;
  4.  
  5. int runLevel = 0;
  6. int servoPin = 5;
  7. int pwmInPin = 4;
  8. int ledPin = 13;
  9.  
  10. void setup() {
  11.  
  12.   pinMode(ledPin, OUTPUT);
  13.   pinMode(pwmInPin, INPUT);
  14.  
  15. }
  16.  
  17. void loop() {
  18.  
  19.   if (runLevel == 0)
  20.     {
  21.     delay(5000);    
  22.     myservo.attach(servoPin);
  23.     runLevel = 1;        
  24.     }
  25.  
  26.   if (runLevel == 1)
  27.   {    
  28.     myservo.writeMicroseconds(500);
  29.     delay(2000);
  30.     digitalWrite(ledPin, HIGH);
  31.     runLevel = 2;
  32.     myservo.detach();
  33.   }
  34.  
  35.   if (runLevel == 2)
  36.   {
  37.     digitalWrite(servoPin,digitalRead(pwmInPin));
  38.   }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement