Skip to content

Instantly share code, notes, and snippets.

@costyn
Created May 9, 2020 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save costyn/39bdcc111d0c3b7ced5bdc15cb02f2b5 to your computer and use it in GitHub Desktop.
Save costyn/39bdcc111d0c3b7ced5bdc15cb02f2b5 to your computer and use it in GitHub Desktop.
#include <stdint.h>
#include <Arduino.h>
#include "MPU6886.h"
static MPU6886 mpu;
void setup(void)
{
Serial.begin(115200);
Serial.println("\nHello World!");
mpu.Init();
}
void loop(void)
{
float x, y, z;
mpu.getAccelData(&x, &y, &z);
int activityLevel = round( (abs( x ) + abs( y ) + abs( z )) / 3 );
if( activityLevel > 5 ) {
Serial.println("Rolling!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment