# Flipping

```
// Do not remove the include below
#include "PlutoPilot.h"
#include "Motor.h"
#include "Control.h"
#include "Estimate.h"
#include "Sensor.h"
#include "Utils.h"
#include "User.h"

int angle;

#define ABS(x) ((x) > 0 ? (x) : -(x))


//The setup function is called once at Pluto's hardware startup
void plutoInit()
{
Motor.initReversibleMotors();
// Add your hardware initialization code here
}



//The function is called once before plutoLoop when you activate Developer Mode
void onLoopStart()
{
LED.flightStatus(DEACTIVATE);
Motor.setDirection(M1,ANTICLOCK_WISE);
Motor.setDirection(M2,CLOCK_WISE);
Motor.setDirection(M3,ANTICLOCK_WISE);
Motor.setDirection(M4,CLOCK_WISE);
  // do your one time stuff here

}



// The loop function is called in an endless loop
void plutoLoop()
{
angle = Angle.get(AG_ROLL);
Monitor.println("Angle is: ", angle);
if (!FlightStatus.check(FS_ARMED))
{
if (ABS(angle)<1800 && ABS(angle)>800)
{
Motor.set(M1, 2000);
Motor.set(M2, 2000);
}
else
{
Motor.set(M1, 1000);
Motor.set(M2, 1000);
Motor.set(M3, 1000);
Motor.set(M4, 1000);
}
}

//Add your repeated code here

}



//The function is called once after plutoLoop when you deactivate Developer Mode
void onLoopFinish()
{
Motor.set(M1, 1000);
Motor.set(M2, 1000);
Motor.set(M3, 1000);
Motor.set(M4, 1000);
Motor.setDirection(M1,CLOCK_WISE);
Motor.setDirection(M2,ANTICLOCK_WISE);
Motor.setDirection(M3,CLOCK_WISE);
Motor.setDirection(M1,ANTICLOCK_WISE);

LED.flightStatus(ACTIVATE);


// do your cleanup stuffs here

}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ptandur14.gitbook.io/everything-about-drone/testing-and-executing-codes/flipping.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
