Skip to content

Instantly share code, notes, and snippets.

@turbinenreiter
Created December 10, 2013 20:41
Show Gist options
  • Save turbinenreiter/7898850 to your computer and use it in GitHub Desktop.
Save turbinenreiter/7898850 to your computer and use it in GitHub Desktop.
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