I'm trying to make a pedometer application with Android using only the accelerometer to gather data. I gathered a lot of raw data from the phone and found certain patterns to constituted a step from my gait and created 3 booleans to model how one step would look like to an accelerometer.
public boolean beforeStep(float y)
{
if(y > 1.5 && y < 3){
return true;
}
else
{
return false;
}
}
public boolean duringStep(float y)
{
if(y > 3 && y < 5){
return true;
}
else
{
return false;
}
}
public boolean afterStep(float y)
{
if(y > 1.5 && y < 3){
return true;
}
else
{
return false;
}
}
if(beforeStep(accel)){
if(duringStep(accel)){
if(afterStep(accel)){
stepCount++;
}
}
}
At first I had run these booleans in my onSensorChanged() method, but I realized that this meant that it would pass the same acceleration value to all three booleans, so the program would never recognize a step. How do I make Android wait, say 10ms, between each boolean check so that the acceleration value updates?
Also, if there is a more accurate/efficient way to go about counting steps using raw acceleration data, please let me know!