资源简介
arduino HMMC5883L - 库文件 支持C与Arduino
arduino示例教程
代码片段和文件信息
/*
HMC5883L.cpp - Class file for the HMC5883L Triple Axis Digital Compass Arduino Library.
Version: 1.1.0
(c) 2014 Korneliusz Jarzebski
www.jarzebski.pl
This program is free software: you can redistribute it and/or modify
it under the terms of the version 3 GNU General Public License as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not see .
*/
#if ARDUINO >= 100
#include “Arduino.h“
#else
#include “WProgram.h“
#endif
#include
#include “HMC5883L.h“
bool HMC5883L::begin()
{
Wire.begin();
if ((fastRegister8(HMC5883L_REG_IDENT_A) != 0x48)
|| (fastRegister8(HMC5883L_REG_IDENT_B) != 0x34)
|| (fastRegister8(HMC5883L_REG_IDENT_C) != 0x33))
{
return false;
}
setRange(HMC5883L_RANGE_1_3GA);
setMeasurementMode(HMC5883L_CONTINOUS);
setDataRate(HMC5883L_DATARATE_15HZ);
setSamples(HMC5883L_SAMPLES_1);
mgPerDigit = 0.92f;
return true;
}
Vector HMC5883L::readRaw(void)
{
v.XAxis = readRegister16(HMC5883L_REG_OUT_X_M) - xOffset;
v.YAxis = readRegister16(HMC5883L_REG_OUT_Y_M) - yOffset;
v.ZAxis = readRegister16(HMC5883L_REG_OUT_Z_M);
return v;
}
Vector HMC5883L::readNormalize(void)
{
v.XAxis = ((float)readRegister16(HMC5883L_REG_OUT_X_M) - xOffset) * mgPerDigit;
v.YAxis = ((float)readRegister16(HMC5883L_REG_OUT_Y_M) - yOffset) * mgPerDigit;
v.ZAxis = (float)readRegister16(HMC5883L_REG_OUT_Z_M) * mgPerDigit;
return v;
}
void HMC5883L::setOffset(int xo int yo)
{
xOffset = xo;
yOffset = yo;
}
void HMC5883L::setRange(hmc5883l_range_t range)
{
switch(range)
{
case HMC5883L_RANGE_0_88GA:
mgPerDigit = 0.073f;
break;
case HMC5883L_RANGE_1_3GA:
mgPerDigit = 0.92f;
break;
case HMC5883L_RANGE_1_9GA:
mgPerDigit = 1.22f;
break;
case HMC5883L_RANGE_2_5GA:
mgPerDigit = 1.52f;
break;
case HMC5883L_RANGE_4GA:
mgPerDigit = 2.27f;
break;
case HMC5883L_RANGE_4_7GA:
mgPerDigit = 2.56f;
break;
case HMC5883L_RANGE_5_6GA:
mgPerDigit = 3.03f;
break;
case HMC5883L_RANGE_8_1GA:
mgPerDigit = 4.35f;
break;
default:
break;
}
writeRegister8(HMC5883L_REG_CONFIG_B range << 5);
}
hmc5883l_range_t HMC5883L::getRange(void)
{
return (hmc5883l_range_t)((readRegister8(HMC5883L_REG_CONFIG_B) >> 5));
}
void HMC5883L::setMeasurementMode(hmc5883l_mode_t mode)
{
uint8_t value;
value = readRegister8(HMC5883L_REG_MODE);
value &= 0b11111100;
value |= mode;
writeRegister8(HMC5883L_REG_MODE value);
}
hmc5883l_mode_t HMC5883L::getMeasurementMode(void)
{
uint8_t value;
value = readRegister8(HM
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 653 2017-07-31 16:54 Arduino-HMC5883L-master\CHANGELOG
....... 5919 2017-07-31 16:54 Arduino-HMC5883L-master\HMC5883L.cpp
....... 3291 2017-07-31 16:54 Arduino-HMC5883L-master\HMC5883L.h
....... 1541 2017-07-31 16:54 Arduino-HMC5883L-master\HMC5883L_calibrate\HMC5883L_calibrate.ino
....... 1837 2017-07-31 16:54 Arduino-HMC5883L-master\HMC5883L_calibrate_MPU6050\HMC5883L_calibrate_MPU6050.ino
....... 1876 2017-07-31 16:54 Arduino-HMC5883L-master\HMC5883L_compass\HMC5883L_compass.ino
....... 2349 2017-07-31 16:54 Arduino-HMC5883L-master\HMC5883L_compass_MPU6050\HMC5883L_compass_MPU6050.ino
....... 3167 2017-07-31 16:54 Arduino-HMC5883L-master\HMC5883L_compensation_ADXL345\HMC5883L_compensation_ADXL345.ino
....... 3293 2017-07-31 16:54 Arduino-HMC5883L-master\HMC5883L_compensation_MPU6050\HMC5883L_compensation_MPU6050.ino
....... 2674 2017-07-31 16:54 Arduino-HMC5883L-master\HMC5883L_processing\HMC5883L_processing.ino
....... 2970 2017-07-31 16:54 Arduino-HMC5883L-master\HMC5883L_processing_MPU6050\HMC5883L_processing_MPU6050.ino
....... 4259 2017-07-31 16:54 Arduino-HMC5883L-master\HMC5883L_simple\HMC5883L_simple.ino
....... 35121 2017-07-31 16:54 Arduino-HMC5883L-master\LICENSE
....... 71472 2017-07-31 16:54 Arduino-HMC5883L-master\Processing\HMC5883L_calibrate_processing\artificialHorizon.png
....... 33031 2017-07-31 16:54 Arduino-HMC5883L-master\Processing\HMC5883L_calibrate_processing\artificialHorizonRing.png
....... 1582 2017-07-31 16:54 Arduino-HMC5883L-master\Processing\HMC5883L_calibrate_processing\HMC5883L_calibrate_processing.pde
....... 65440 2017-07-31 16:54 Arduino-HMC5883L-master\Processing\HMC5883L_compensation_processing\compass.png
....... 56282 2017-07-31 16:54 Arduino-HMC5883L-master\Processing\HMC5883L_compensation_processing\compassPlateBlack.png
....... 56429 2017-07-31 16:54 Arduino-HMC5883L-master\Processing\HMC5883L_compensation_processing\compassPlateWhite.png
....... 34504 2017-07-31 16:54 Arduino-HMC5883L-master\Processing\HMC5883L_compensation_processing\compassRing.png
....... 7323 2017-07-31 16:54 Arduino-HMC5883L-master\Processing\HMC5883L_compensation_processing\HMC5883L_compensation_processing.pde
....... 65440 2017-07-31 16:54 Arduino-HMC5883L-master\Processing\HMC5883L_processing\compass.png
....... 56282 2017-07-31 16:54 Arduino-HMC5883L-master\Processing\HMC5883L_processing\compassPlateBlack.png
....... 56429 2017-07-31 16:54 Arduino-HMC5883L-master\Processing\HMC5883L_processing\compassPlateWhite.png
....... 34504 2017-07-31 16:54 Arduino-HMC5883L-master\Processing\HMC5883L_processing\compassRing.png
....... 7821 2017-07-31 16:54 Arduino-HMC5883L-master\Processing\HMC5883L_processing\HMC5883L_processing.pde
....... 934 2017-07-31 16:54 Arduino-HMC5883L-master\README.md
目录 0 2018-02-06 12:38 Arduino-HMC5883L-master\Processing\HMC5883L_calibrate_processing
目录 0 2018-02-06 12:38 Arduino-HMC5883L-master\Processing\HMC5883L_compensation_processing
目录 0 2018-02-06 12:38 Arduino-HMC5883L-master\Processing\HMC5883L_processing
............此处省略14个文件信息
- 上一篇:AjaxLogin.rar
- 下一篇:图形学课程设计运动的小球
相关资源
- hmc5883l 与51单片机接线图
- arduino_LiquidCrystal_I2C库及proteus仿真LC
- Arduino_IRremote_master.zip
- Arduino中文手册
- Arduino Mini 资料
- 基于Arduino与LabVIEW的数据采集系统.v
- Arduino通过Ethernet扩展板实现网络远程
- 基于Arduino的-亚博 BST-BATCAR 智能小车底
- Arduino的PID库
- 基于labview和arduinod的超声波测距
- Arduino UNO R3开发板原理图
- 移送气象站 arduino代码
- Arduino Nano v3.0介绍及原理图pdf
- arduino pro mini 封装、pcb图及原理图
- arduino mega 2560 原理图
- 自平衡小车arduino+mpu6050+卡尔曼滤波
- HMC5883L的Arduino库
-
DFPla
yer_Mini_mp3 arduino 库文件 - arduino avrdude 5.11.1 for Windows with JesseJ
- Arduino I2Cdev库
- arduino鼠标点击绝对坐标
- 74LS47驱动7段数码管实验
- usbser.sys和mdmcpq.PNF和mdmcpq.inf还有另一
- CC2530-HMC5883L通过I2C通信
- 自动计算mpu6050的偏移量MPU6050_calibra
- XLoader hex文件
- arduino-uno-r3 电路图
- 颜色传感器ARDUINO代码
- PS2手柄 - arduino版本例程
- RFID.h RC522
评论
共有 条评论