Results 1 to 2 of 2
  1. #1
    25+ Posting Member
    Join Date
    Sep 2013
    Location
    Lahore
    Posts
    33
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Vertical Speed indicator, servo, help

    so i decided to play with the servo that i just bought. after going through some tutorial sketches, i decided to modify Jim's, code to accomodate the servo. logically, the sketch makes sense to me. but i cant figure out what im doin wrong. can anyone help? i know that ive connected it correctly to the board.
    also, i read somewhere, that you dont need PWM for servos. is that true? because we dont need to modulate the pulse for a servo. it can work on a steady signal. we can simply write a code.

    Code:
    #include    
    VarSpeedServo myservo; 
    int j1;
    String VSI;
    
    
    void setup() {
    myservo.attach(9); //attaching servo to pin 9 
    Serial.begin(115200); 
    Serial.flush(); 
    }
     
    void loop() {
      if (Serial.available() > 0) {
        j1 = Serial.read();
        if (j1 == 'T'){    
          delay (11); 
          VSI = "";
          VSI += char(Serial.read());
          VSI += char(Serial.read());
          VSI += char(Serial.read());
          VSI += char(Serial.read());
          int VSIInt = VSI.toInt(); // convert it to an integer 
          VSIInt = map(VSIInt, -4000, 4000, 0 ,179);//map the integer
          myservo.write(VSIInt); 
        }//end of found "T"
      }//end of serial read
    }//end of void loop
    the libraby used above is

  2. #2
    500+ This must be a daytime job Jim NZ's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    764
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Vertical Speed indicator, servo, help

    I see your using the varspeedservo library ,,, something I haven't fiddled with yet.

    But ,,,, flicking thru it's sample at their site ,,,

    myservo1.write(180,127,false); // move the servo to 180, fast speed, run background
    // write(degrees 0-180, speed 1-255, wait to complete true-false)

    myservo2.write(180,127,true); // move the servo to 180, fast speed, wait until done

    So your line ,,,
    myservo.write(VSIInt);
    is wrong for that library ????

    I'm guessing it should be something like this ,,,
    myservo.write(VSIInt, 127,false);

    But ,, there again ,, I could be wrong ,,,, Jim

    p.s. Note ,, that library is good for only 8 servo's ,, something to keep in mind.
    www.jimspage.co.nz/intro.htm
    All this and Liz still loves me ! !