ArduPilot - Customize Analog Pins

Hi,

How can I programm the analog pins? I want to have 2 buttons (on computer or remote control). If one of these buttons is pressed there must be a high signal (+5v or +3.3V) on analog pin (A1, A2, or A3....). Each button wil have his one analog pin.

Is ths possible?

Greets, Gert-Jan

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • http://diydrones.com/forum/topics/relay-or-making-one-pin-5v-on-2-5...

    So I write on blank page (everything commented out) (APM_config.h)?, so I did  :

    I defined analog 8 to be output (61 according to this) in :

    # define RELAY            61 // is AN8

    #define pinMode(RELAY, OUTPUT);

    And in  arduplane.pde I made some robust? changes:

    original:

    static void one_second_loop()
    {

    if (g.log_bitmask & MASK_LOG_CUR)
    Log_Write_Current();

    // send a heartbeat
    gcs_send_message(MSG_HEARTBEAT);
    }

    My cahnges:

    int sec=0; //added sec integer
    static void one_second_loop()
    {

    if (sec==300){   //after 5 min
    analogWrite(RELAY, 255);} // hold the an8 at 5v 

    if (sec==305){                  
    analogWrite(RELAY, 0); sec=0;}   //hold 5v for 5 sek, and reset integer sec back to 0.


    if (g.log_bitmask & MASK_LOG_CUR)
    Log_Write_Current();


    // send a heartbeat
    gcs_send_message(MSG_HEARTBEAT);
    sec++;  //add +1 on every loop
    }

     

  • Developer

    You could use something like this ServoSwitch and then attach it to a servo out on the APM and use the DO_SET_SERVO.  A more direct approach would be to use the DO_SET_RELAY command.  i can't actually guarantee it works on ArduPlane.  I think it works on arducopter...

  • Is there reason you want to use the analog pins instead of the digital pins for a button actuated signal? You may program the use of any analog/digital I/O pin you want, but, please be sure that the APM software is not already utilizing the pins you want to use.

This reply was deleted.

Activity