#include #include #include #include int numberOfSteps; void setup(){ EngduinoAccelerometer.begin(); EngduinoButton.begin(); numberOfSteps = 0; } //the same as main() this function will keep looping and will run the main program void loop(){ //Code to get the acceleration from the accelerometer float accelerations[3]; EngduinoAccelerometer.xyz(accelerations); float x = accelerations[0]; float y = accelerations[1]; float z = accelerations[2]; float a = sqrt(x*x + y*y + z*z); Serial.print("Acceleration: = "); Serial.println(a); /*Checks acceleration against current Limit and sees if it is greater than 1.5 and adds step if this is true. Also checks to make sure that no infinite values are allowed through*/ if (a >= 1.5 && a < 2){ addStep(numberOfSteps); delay(50); } delay(250); } void addStep(int numberOfSteps){ numberOfSteps ++; Serial.println("Number of Steps: = "); Serial.println(numberOfSteps); }