Quantcast
Viewing all articles
Browse latest Browse all 45679

Using arduino as a remote control for apm 2.8

@Willy wrote:

Hi, i want question if anybody has armed a InspireOne with 3D parts with ardupilot 2.8 APM, I made simulate the RC with arduino nano and Joystick in a Mision Planer and recognize the entries but show a message DISARMED in the Fligh Data, somebody can say how I can ARM this ardupilot to move the motors?

this is the arduino nano code:

Servo

int pos;

int joy1x;
int joy1y;
int joy2x;
int joy2y;

Servo acelerador;
Servo girar_sobre_eje;
Servo avan_frente;
Servo avan_atras;

void setup(){
  Serial.begin(9600);
  acelerador.attach(2);
  girar_sobre_eje.attach(3,1000,2000);
  avan_frente.attach(4,1000,2000);
  avan_atras.attach(5,1000,2000);

  //Funcion armar
  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                                     // in steps of 1 degree
    acelerador.write(pos);                  // tell servo to go to position in variable 'pos'
    delay(50);                                    // waits 15ms for the servo to reach the position
  }
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  {
    write(pos);                                    // tell servo to go to position in variable 'pos'
    delay(50);                                     // waits 15ms for the servo to reach the position
  }
}
void loop(){
joy1x=analogRead(0);
joy1y=analogRead(1);
joy2x=analogRead(2);
joy2y=analogRead(3);

acelerador.write(map(joy1x, 0, 1023, 0, 180));
girar_sobre_eje.write(map(joy1y, 0, 1023, 0, 180));
avan_frente.write(map(joy2x, 0, 1023, 0, 180));
avan_atras.write(map(joy2y, 0, 1023, 0, 180));
delay(50);
Serial.println(joy1x);
Serial.println(joy1y);
Serial.println(joy2x);
Serial.println(joy2y);
delay(50);

}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 45679

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>