Create a gist now

Instantly share code, notes, and snippets.

Arduino code to send acceleration data to serial port.
#include <MPU6050.h>
#include <I2Cdev.h>
#include <Wire.h>
MPU6050 accelgyro;
int ax, ay, az;
int gx, gy, gz;
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
Wire.begin();
accelgyro.initialize();
pinMode(led, OUTPUT);
digitalWrite(led, HIGH);
accelgyro.setFullScaleAccelRange(1);
}
// the loop routine runs over and over again forever:
void loop() {
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
Serial.println(ax);
delay(50);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment