Results 1 to 8 of 8
  1. #1
    New Member
    Join Date
    Jul 2012
    Location
    Netherlands
    Posts
    4
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    simple example link2fs servo control needed

    Hi,
    I am new here and tried to find a solution for my problem.
    This is what I want.

    Read the link2fs output to arduino (uno) and control a servo.
    For example I read the link2fs output 'engine rpm' which is sent to arduino as 'Q01528' (1528 rpm)
    I want a servo to respond to that.

    I know about programming in basic a long time ago but I tried to write the arduino c+ but cannot get it working.

    Can someone write these few lines for me so from there I try to make some other servo's move.
    I think maybe only 10 - 15 lines?

    Please help me on the way.

    Thanks in advance

  2. #2
    New Member
    Join Date
    Jul 2012
    Location
    Netherlands
    Posts
    4
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: simple example link2fs servo control needed

    I tried this line 'pitch = char(Serial.read());' gives an error. Anyone know the solution?

    #include
    Servo myservopitch;

    int j1;
    String pitch, pitchold;


    void setup()
    {
    myservopitch.attach(9);

    Serial.begin(57600);
    }

    void loop()
    {
    if (Serial.available() > 0) {
    j1 = Serial.read();
    if (j1 == 'A'){
    delay (5);
    pitch = char(Serial.read());
    pitch += char(Serial.read());
    pitch += char(Serial.read());
    pitch += char(Serial.read());
    pitch += char(Serial.read());
    if (pitch != pitchold){
    char carray[7];
    pitch.toCharArray(carray, sizeof(carray));
    int n = atoi(carray);
    n = map(n, -10, 10, 45, 90);
    myservopitch.write(n);
    pitchold = pitch;
    }
    }
    }

    }

  3. #3
    500+ This must be a daytime job



    Join Date
    Oct 2009
    Location
    Juneau, AK
    Posts
    619
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: simple example link2fs servo control needed

    Check out this thread:

    http://www.mycockpit.org/forums/show...-mail-now-what

    Post 14 should help a great deal. It has a heavily annotated example to start with.

    Reid
    http://juneaucessnasim.blogspot.com
    N58243 (virtual)- Low and Slow...

  4. #4
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    May 2012
    Location
    SC, USA
    Posts
    9
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: simple example link2fs servo control needed

    I'm seeing several potential sources... what specific error did you get?

    at a glanse, doesn't atoi() expect a pointer to a string, not a single character...

    something like

    char * this_val = &carrary[0];
    int Int_val = atio(this_val);

    I think...

    here is another simple servo sketch... data is fed from an I2C master

    Flap Indicator Slave
    Don't know a thing....
    Making slow progress at www.erj145.com

  5. #5
    New Member
    Join Date
    Jul 2012
    Location
    Netherlands
    Posts
    4
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: simple example link2fs servo control needed

    Hi,

    The problem is in this line: vertsp = char(Serial.read()); // first digit of the data

    I get these error messages:
    vertical_speed_working.cpp: In function 'void loop()':
    vertical_speed_working:17: error: invalid conversion from 'char' to 'const char*'
    vertical_speed_working:17: error: initializing argument 1 of 'String& String:perator=(const char*)'

    I really don't know the solution.

    However if I load the code in an older version arduino (v 022) there is no problem.
    When using the latest one I get the errors.

    Jerome

  6. #6
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    May 2012
    Location
    SC, USA
    Posts
    9
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: simple example link2fs servo control needed

    pitch = "Serial.read()";
    pitch += "Serial.read()";
    ...

    Should take care of the error
    Don't know a thing....
    Making slow progress at www.erj145.com

  7. #7
    New Member
    Join Date
    Jul 2012
    Location
    Netherlands
    Posts
    4
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: simple example link2fs servo control needed

    Quote Originally Posted by Tony_ERJ145 View Post
    pitch = "Serial.read()";
    pitch += "Serial.read()";
    ...

    Should take care of the error
    This is not working. Servo does not move. I tried this: pitch = (0); which is working ok.
    Still wondering why the latest arduino software give me error messages

    Jerome

  8. #8
    10+ Posting Member
    Join Date
    May 2012
    Location
    Var, France
    Posts
    12
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: simple example link2fs servo control needed

    Hi,
    i see :
    void setup()
    {
    myservopitch.attach(9);

    Serial.begin(57600); // try 115200
    }

    void loop()...
    and what is Arduino version used ? Because 1.0 or 1.0.1 not work, you must use v 22 or v 23

    look at this : http://www.mycockpit.org/forums/show...l=1#post131846

    See you... FX

  9. Thanks AK Mongo thanked for this post

Tags for this Thread