查看(SKU:RB-02S077)三轴数字罗盘 HMC5883L的源代码
←
(SKU:RB-02S077)三轴数字罗盘 HMC5883L
跳转至:
导航
、
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
[[文件:3zszlp.jpg|500px|缩略图|右]] ==产品概述== HMC5883L是奥松机器人最引进的Sparkfun原装进口的三轴数字罗盘。通过I2C接口并提供2.16-3.6V的稳定电压就可以与HMC5883L完美连接,它可用于各种轮式机器人导航装置。 此款三轴数字罗盘内含HMC5883L测量芯片,可作为各种轮式机器人导航装置,可装在Boe-Bot Kit机器人上,从而做到方位识别定位的作用。附送PC机控制软件,人机介面简洁便于操作与观测,控制器源程序开放,短暂时刻即可架设完成数字式电子罗 盘。可与多种单片机融合,与BASIC Stamp,Javalin Stamp,以及SX 全系列完全相容。 ==规格参数== #工作电压 :2.16V~3.6V #工作电流:100uA(测量模式) #最大输出频率 :160Hz #磁场有效宽度:(+/-8 gauss) #罗盘航向精度:1~2度 #通信接口:I2C #尺寸大小: 17.78x17.78mm ==接口定义== *GND:地(GND) *VIN:电源(VCC) *SCL:时钟信号 *SDA:数据信号 [[文件:3zszlp1.jpg|700px|缩略图|居中]] ==使用方法== ===接线方法=== SCL和SDA端口分别接到控制器的模拟5和4 I/O口。VIN和GND分别接到电源的3.3V和GND。 [[文件:RB02S07701.png|500px|缩略图|居中]] ===例子程序=== 依照程序将三轴数字罗盘与UNO连接,观察串口输出的X、Y、Z 三轴数据。 <pre style='color:blue'> /* An Arduino code example for interfacing with the HMC5883 Analog input 4 I2C SDA Analog input 5 I2C SCL */ #include <Wire.h> //I2C Arduino Library #define address 0x1E //0011110b, I2C 7bit address of HMC5883 void setup(){ //Initialize Serial and I2C communications Serial.begin(9600); Wire.begin(); //Put the HMC5883 IC into the correct operating mode Wire.beginTransmission(address); //open communication with HMC5883 Wire.write(0x02); //select mode register Wire.write(0x00); //continuous measurement mode Wire.endTransmission(); } void loop(){ int x,y,z; //triple axis data //Tell the HMC5883 where to begin reading data Wire.beginTransmission(address); Wire.write(0x03); //select register 3, X MSB register Wire.endTransmission(); //Read data from each axis, 2 registers per axis Wire.requestFrom(address, 6); if(6<=Wire.available()){ x = Wire.read()<<8; //X msb x |= Wire.read(); //X lsb z = Wire.read()<<8; //Z msb z |= Wire.read(); //Z lsb y = Wire.read()<<8; //Y msb y |= Wire.read(); //Y lsb } //Print out values of each axis Serial.print("x: "); Serial.print(x); Serial.print(" y: "); Serial.print(y); Serial.print(" z: "); Serial.println(z); delay(250); } </pre> ===程序效果=== 打开串口监视器可以观察到输出的X、Y、Z 三轴数据。 [[文件:RB02S07710.png|300px|缩略图|居中]] ==产品相关推荐== [[文件:erweima.png|230px|无框|右]] ===产品购买地址=== [http://www.alsrobot.cn/goods-588.html Sparkfun HMC5883L三轴数字罗盘传感器]<br/> ===周边产品推荐=== [https://item.taobao.com/item.htm?spm=a1z10.3-c.w4002-3667083713.14.QyL8Qd&id=18722272286 ADXL335模块三轴加速度模块]<br/> [https://item.taobao.com/item.htm?spm=a1z10.3-c.w4002-3667083713.17.QyL8Qd&id=13280714814 Arduino ADXL345 三轴加速度计]<br/> [https://item.taobao.com/item.htm?spm=a1z10.3-c.w4002-3667083713.20.QyL8Qd&id=522174307810 Arduino 9 Axes Motion Shield 9轴运动扩展板]<br/> ===相关问题解答=== ===相关学习资料=== [https://www.sparkfun.com/tutorials/301 HMC5883L Breakout Quickstart Guide]<br/> [http://dlnmh9ip6v2uc.cloudfront.net/datasheets/BreakoutBoards/HMC5883L_Breakout-v11.pdf 电路原理图]<br/> [http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Magneto/HMC5883L-FDS.pdf HMC5883L 数据手册]<br/> [http://pan.baidu.com/s/1ntD14VZ 三轴数字罗盘 HMC5883L 设计参考 Eagle 文件下载]<br/> [http://www.makerspace.cn/portal.php 奥松机器人技术论坛]<br/>
返回
(SKU:RB-02S077)三轴数字罗盘 HMC5883L
。
导航菜单
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面
页面信息