Using CurieIMU step detection in an IF condition

Hi there,

I'm thinking of combining features from both the orientation visualiser and step counter examples to set up a foot based dead reckoning system, would it be possible to implement this code:

  if (CurieIMU.stepsDetected() == HIGH)
  {
    vx = 0;
    vy = 0;
    vz = 0;
  }
  else 
  {
  vx += anew_x * 0.0025;
  vy += anew_y * 0.0025;
  vz += anew_z * 0.0025;
  }

which zeroes velocity when the foot hits the ground? It doesn't seem to work properly when I tried running the code.

Cheers :slight_smile:

One thing I noticed: CurieIMU.stepsDetected() returns a bool (true or false), not a pin level (HIGH or LOW). So your if statement should be something like if (CurieIMU.stepsDetected()) instead of comparing CurieIMU.stepsDetected() to HIGH or LOW.