陀螺儀 加速度計 MPU-6050
MEMS陀螺儀(Gyroscope):角速度計,測量單位 角速度(度/秒)
例如:
LPY530AL Dual
加速度感測器:
測量加速度的裝置,也就是g force
例如:
三軸加速度感測器 ADXL335
http://www.eettaiwan.com/ART_8800701519_480502_TA_e52a9104.HTM?jumpto=view_welcomead_1417248841196
https://www.youtube.com/watch?v=F50Fea3My1Q
MPU-6050
MPU6050 三軸陀螺儀+三軸加速度 6軸模組
規格
I²C函式庫http://www.i2cdevlib.com/devices/mpu6050#source
https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050
http://ming-shian.blogspot.tw/2014/05/arduino21mpu6050row-data.html
http://gogoprivateryan.blogspot.tw/2014/07/mpu-6050-google.html#include "I2Cdev.h"
#include "MPU6050.h"
#include "Wire.h"
#include <Servo.h>
MPU6050 accelgyro;
Servo servo1;
int16_t ax, ay, az;
int16_t gx, gy, gz;
int val;
int prev;
void setup() {
Wire.begin();
Serial.begin(38400);
Serial.println("Initializing I2C devices...");
accelgyro.initialize();
servo1.attach(7);
// verify connection
Serial.println("Testing device connections...");
Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
}
void loop() {
// read raw accel/gyro measurements from device
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
Serial.print("a/g:\t");
Serial.print(ax); Serial.print("\t");
Serial.print(ay); Serial.print("\t");
Serial.print(az); Serial.print("\t");
Serial.print(gx); Serial.print("\t");
Serial.print(gy); Serial.print("\t");
Serial.println(gz);
val = map(ay,-17000,17000,0,179);
if (val!=prev){
servo1.write(val);
prev=val;
}
delay(50);
}
頁:
[1]