Detect-360-yaw-roll-pitch

Hi everyone,

I have a little project with ArduIMUV3.

The point is to detect a complete revolution 360° on roll, pitch and yaw axis, and lit up one of the leds.

I can’t find where is the part in ArduIMU 1.9 code that gives the initial values of roll pitch and yaw, I would like to use these as my initial conditions to start counting a rotation on each axis.

I have tried and adapted this code found on the web for yaw, add it to the DCM file and call the function in arduimu file but no chance, also because I don’t know how to get the initial values:

void ThreeSixty(float ActualYAW)
{
float prev_yaw;
float yawDeg = ToDeg(ActualYAW);
boolean cp_pi;
float yaw = yawDeg;
Serial.println(yawDeg);
if ((yaw == 180) || (yaw == 0)) return;

if (yaw * prev_yaw < 0)
{

float d_yaw = (yaw - prev_yaw);
if (d_yaw < 0)
{
cp_pi = ! cp_pi;
}
else if (cp_pi)
{
// fire detection event
Serial.print(“ThreeSixtyYAW");
Serial.print(ActualYAW);
Serial.print("
”);
digitalWrite(RED_LED_PIN,HIGH);
digitalWrite(BLUE_LED_PIN,LOW);
}
}
prev_yaw = yaw;
}

Thanks a lot,

Best Regards,

arduimu.pde (20.1 KB)

DCM.pde (11.3 KB)

DCM.pde is a Processing sketch. I don't think you can add anything to the Processing sketch running on the PC that you can then 'call' from the Arduino sketch.

Hi John,

Thanks for you answer
I am not sure I understand well what you are saying, is it that it should not work?
Because it seems to work at least when I got 45° roll, the blue led is lit up, I guess it means that this code is processed.
By the way, where should I put this code then?

Do you have any idea on how to do the 360° detection?
How can I keep the led on during 10s if this movement is detected?

Thanks a lot.

Best Regards,