找传奇、传世资源到传世资源站!

HMC5883L范例

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

/* ****************************************************************************** * @file : main.c * @Copyright: ViewTool * @Revision : ver 1.0 * @Date : 2014/12/19 11:14 * @brief : MPU6050 demo ****************************************************************************** * @attention * * Copyright 2009-2014, ViewTool * http://www.viewtool.com/ * All Rights Reserved * ****************************************************************************** */#include <stdio.h>#include "HMC5883L.h"#include "ControlI2C.h"int main(void){enum Status status;status = HMC5883L_Init();if(status != SUCCESS){printf("Initialize HMC5883L failed!\n");return 0;}// if config failed, please step into this function, give each function call a short delay time, it will work.status = HMC5883L_Config();if(status != SUCCESS){printf("Config HMC5883L failed!\n");return 0;} while (1) {int16_t XMagnetic, YMagnetic, ZMagnetic; //Get datastatus = HMC5883L_ReadMagnetic(&XMagnetic, &YMagnetic, &ZMagnetic);if(status != SUCCESS){printf("Get Magnetic failed!\n");return 0;} //Display data // system("cls"); printf("XMagnetic= %d\n" , XMagnetic); printf("YMagnetic= %d\n" , YMagnetic); printf("ZMagnetic= %d\n" , ZMagnetic); Sleep(100); }return 0;}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复