欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
STM32 MPU6050獲取加速度角速度代碼
[打印本頁]
作者:
wind@
時間:
2018-12-27 14:06
標題:
STM32 MPU6050獲取加速度角速度代碼
MPU6050三軸陀螺儀通過IIC讀取獲取角速度及加速度代碼
單片機源程序如下:
//連接方式 :請參考interface.h文件
//部份源碼來源網絡--請試用24小時后刪除
#include "stm32f10x.h"
#include "interface.h"
#include "LCD1602.h"
#include "IRCtrol.h"
#include "motor.h"
#include "UltrasonicCtrol.h"
#include "redvoid.h"
#include "Usart_Interrupt.h"
#include "stm32f10x_i2c.h"
#include "MPU_IIC.h"
#include "uart.h"
#include "usart.h"
u8 pBuffer;
u8* ppBuffer;
s16 AccelGyro[7]={0};
unsigned char cmd_flag = 0;
unsigned char testbuf[5]="abcdf";
//全局變量定義
unsigned int speed_count=0;//占空比計數器 50次一周期
char front_left_speed_duty=SPEED_DUTY;
char front_right_speed_duty=SPEED_DUTY;
char behind_left_speed_duty=SPEED_DUTY;
char behind_right_speed_duty=SPEED_DUTY;
unsigned char tick_5ms = 0;//5ms計數器,作為主函數的基本周期
unsigned char tick_1ms = 0;//1ms計數器,作為電機的基本計數器
unsigned char tick_200ms = 0;//刷新顯示
char ctrl_comm = COMM_STOP;//控制指令
char ctrl_comm_last = COMM_STOP;//上一次的指令
unsigned char continue_time=0;
int main(void)
{
delay_init();
USART1Conf(115200);
// printf("MPU6050 test1--->\n");
I2C_MPU6050_Init();
// printf("MPU6050 test2--->\n");
MPU6050_IniTIalize();
// printf("MPU6050 test3--->\n");
while(1)
{
//MPU6050_I2C_ByteWrite(SlaveAdress,pBuffer,0x68);
//MPU6050_I2C_ByteWrite(u8 slaveAddr, u8 pBuffer, u8 writeAddr)
//MPU6050_I2C_BufferRead(SlaveAdress,ppBuffer,0x68,8);//NumByteToRead?
//MPU6050_I2C_BufferRead(u8 slaveAddr, u8* pBuffer, u8 readAddr, u16 NumByteToRead)
MPU6050_GetRawAccelGyro(AccelGyro);
printf("MPU6050 test3--->\r\n");
// printf("ACC_X = %10.5d\r\n",AccelGyro[0]);
// printf("ACC_Y = %10.5d\r\n",AccelGyro[1]);
// printf("ACC_Z = %10.5d\r\n",AccelGyro[2]);
// printf("GYRO_X = %10.5d\r\n",AccelGyro[3]);
// printf("GYRO_Y = %10.5d\r\n",AccelGyro[4]);
// printf("GYRO_Z = %10.5d\r\n",AccelGyro[5]);
printf("ACC_X = %d\r\n",AccelGyro[0]);
printf("ACC_Y = %d\r\n",AccelGyro[1]);
printf("ACC_Z = %d\r\n",AccelGyro[2]);
printf("GYRO_X = %d\r\n",AccelGyro[3]);
printf("GYRO_Y = %d\r\n",AccelGyro[4]);
printf("GYRO_Z = %d\r\n",AccelGyro[5]);
Delay_us(500000);
}
}
復制代碼
所有資料51hei提供下載:
MPU6050.7z
(190.45 KB, 下載次數: 84)
2018-12-28 02:03 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
作者:
chaqs3
時間:
2019-8-23 15:52
AccelGyro前三個代表的是xyz軸上的加速度嗎?
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1