一、线路连接

Arduino MPU6050
VCC 3.3V/5V
GND GND
SCL A5
SDA A4
INT D2

二、库下载

https://pan.baidu.com/s/1nvt75tJ

下载后,将相关库文件放进Arduino的libraries文件夹中

三、示例代码

// I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 class
// 10/7/2011 by Jeff Rowberg <jeff@rowberg.net>
// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
//
// Changelog:
// 2011-10-07 - initial release /* ============================================
I2Cdev device library code is placed under the MIT license
Copyright (c) 2011 Jeff Rowberg Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================
*/ // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
// is used in I2Cdev.h
#include "Wire.h" // I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files
// for both classes must be in the include path of your project
#include "I2Cdev.h"
#include "MPU6050.h" // class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for InvenSense evaluation board)
// AD0 high = 0x69
MPU6050 accelgyro; int16_t ax, ay, az;
int16_t gx, gy, gz; #define LED_PIN 13
bool blinkState = false; void setup() {
// join I2C bus (I2Cdev library doesn't do this automatically)
Wire.begin(); // initialize serial communication
// (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
// it's really up to you depending on your project)
Serial.begin(); // initialize device
Serial.println("Initializing I2C devices...");
accelgyro.initialize(); // verify connection
Serial.println("Testing device connections...");
Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed"); // configure Arduino LED for
pinMode(LED_PIN, OUTPUT);
} void loop() {
// read raw accel/gyro measurements from device
// accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
int16_t temp = accelgyro.getTemperature();
int16_t tempx = + ( temp / 333.87 ); // these methods (and a few others) are also available
//accelgyro.getAcceleration(&ax, &ay, &az);
//accelgyro.getRotation(&gx, &gy, &gz); // display tab-separated accel/gyro x/y/z values
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);
Serial.println(tempx);
Serial.println("================================"); // blink LED to indicate activity
blinkState = !blinkState;
digitalWrite(LED_PIN, blinkState);
}

四、其他

1.其他方法可以在库文件的MPU6050.cpp中查看

2.温度传感器用于零漂校准,用于测温度不准

Arduino连接MPU6050陀螺仪的更多相关文章

  1. 使用MPU6050陀螺仪自制Arduino数字量角器

    MPU6050惯性单元是一个3轴加速度计和一个3轴陀螺仪组合的单元.它还包含温度传感器和DCM,可执行复杂的任务. MPU6050通常用于制作无人机和其他远程控制机器人,如自平衡机器人.在本篇文章中, ...

  2. 使用Arduino开发板实现与MPU6050陀螺仪传感器连接的方法

    MPU6050陀螺仪传感器具有许多强大的功能,采用单芯片封装.它是由一个MEMS加速度计.一个MEMS陀螺仪和温度传感器组成.该模块在将模拟量转换为数字量时非常准确,因为每个通道都有一个16位的模数转 ...

  3. Arduino连接pH计

    关于arduino连接ph,核心的东西就是对ph传感器返回的信号值进行一系列的操作,注意因为返回的信号很弱,而且外部环境对其影响也很大,所以需要在电路设计上加入一些功能,比如信号放大.滤波等,电路设计 ...

  4. arduino连接1602LCD方法

    arduino连接1602LCD方法 参考代码:

  5. arduino连接12864LCD方法

    arduino连接12864LCD方法,参考相关代码. https://blog.csdn.net/txwtech/article/details/95038386

  6. Arduino连接L298n驱动板驱动小车的电机

    1.L298N介绍 先来讲讲电机驱动,驱动一般使用L298N,L298N 是一种双H桥电机驱动芯片,其中每个H桥可以提供2A的电流,功率部分的供电电压范围是2.5-48v,逻辑部分5v供电,接受5vT ...

  7. Arduino连接SHT10温湿度传感器--返回值不正常解决办法

    如题目,arduino中连接温湿度传感器,用的是一个github开源项目,地址:点击打开,其实这个就是一个封装好的库,下载后把解压的文件夹复制到Arduino目录下的librarys文件夹内,重启Ar ...

  8. 使用Arduino连接HC-SR04超声波距离传感器的方法

    距离传感器是机器人项目最有用的传感器之一. HC-SR04是一种便宜的超声波距离传感器,可以帮助您的机器人在房间周围导航.通过一些努力和一个额外的组件,它也可以用作测量设备.在这篇文章中,您将学习到通 ...

  9. Arduino连接LCD1602显示屏

    简介 LCD1602是一种工业字符型液晶,能够同时显示16x02即32个字符.LCD1602液晶显示的原理是利用液晶的物理特性,通过电压对其显示区域进行控制,即可以显示出图形.[百度百科] 引脚说明 ...

随机推荐

  1. 精通CSS:高级Web标准解决方案(第二版) 初读笔记

    2.1 常用的选择器 1. 类型选择器  p { color: black; } 2. 后代选择器  blockquote p { padding-left: 2em; } 3. ID选择器  #in ...

  2. 磊哥的密码箱icpc11526

    问题 D: 磊哥的密码箱 时间限制: 1 Sec  内存限制: 128 MB提交: 238  解决: 61[提交] [状态] [命题人:admin] 题目描述 磊哥有个密码箱,里面装的都是令磊哥羞羞的 ...

  3. word2vec高效训练方法

    在word2vec原理中讲到如果每个词向量由300个元素组成,并且一个单词表中包含了10000个单词.回想神经网络中有两个权重矩阵——一个在隐藏层,一个在输出层.这两层都具有300 x 10000 = ...

  4. VMware下的Centos7联网并设置固定IP(nat)

    命令:vi /etc/sysconfig/network-scripts/ifcfg-ens33 如下图所示,加上这四行内容. IPADDR 需要是和网关在同一网段 GATEWAY 参考在虚拟机的na ...

  5. [Codeforces 1245D] Shichikuji and Power Grid (最小生成树)

    [Codeforces 1245D] Shichikuji and Power Grid (最小生成树) 题面 有n个城市,坐标为\((x_i,y_i)\),还有两个系数\(c_i,k_i\).在每个 ...

  6. Centos7安装elasticsearch6.3及ik分词器,设置开机自启

    参考Elasticsearch 在CentOs7 环境中开机启动 建议虚拟机的内存大小为4G 1. 新建一个用户john 出于安全考虑,elasticsearch默认不允许以root账号运行. 创建用 ...

  7. mysql表优化

    一.定期分析表 ANALYZE [LOCAL | NO_WRITE_TO_BINLOG] TABLE tbl_name [, tbl_name] 二.定期检查表 CHECK TABLE tbl_nam ...

  8. Linux端口是否占用的方法

    1.netstat或ss命令 netstat -anlp | grep 80 2.lsof命令 这个命令是查看进程占用哪些文件的 lsof -i:80 3.fuser命令 fuser命令和lsof正好 ...

  9. P1397 [NOI2013]矩阵游戏

    传送门 首先显然可以矩乘快速幂然后 $T$ 飞 看一眼题解发现因为这一题矩阵的特殊性所以可以对矩阵的次数欧拉降幂 然而我并不懂证明,所以我选择暴力乱搞的做法 十进制快速幂,然后注意一下常数,还有矩阵乘 ...

  10. Mac中如何查看电脑的IP地址

    方法一:使用ifconfig命令 方法二:在charles中查看 Charles 的顶部菜单的 “Help”->”Local IP Address”,即可在弹出的对话框中看到 IP 地址,如下图 ...