国产免费AV|泡泡玛特欧洲总部将设在伦敦|中文天堂网www新版资源在线|一本久道综合在线中文|国精产品一二三产区的使用方法|香蕉鱼在线观看|www.27eee
ELEOK
標題:
STM32F0驅動adxl345,串口打印數據 源程序
[打印本頁]
作者:
路漫漫
時間:
2020-5-29 02:08
標題:
STM32F0驅動adxl345,串口打印數據 源程序
STM32F0 iic協議驅動adxl345,串口打印數據
完整源碼stm32f0 adxl345.7z
(192.71 KB, 售價: 1 E幣)
2020-5-29 02:07 上傳
點擊文件名下載附件
售價: 1 E幣
[記錄]
[
購買
]
部分源碼
#include "include.h"
#include "iic.h"
#include "adxl345.h"
#include "stm32f0xx.h"
#include "stm32f0_discovery.h"
#include "usart.h"
#include "oled.h"
int main(void)
{
short x,y,z;
int angx,angy,angz;
delay_init();
USART_Configuration();
I2C_INIT();
while(ADXL345_Init())
{
USART1_SendString("傳感器初始失敗\r\n");
}
USART1_SendString("傳感器初始化成功\r\n");
USART1_SendString("正在校準……\r\n");
ADXL345_AUTO_Adjust(&x, &y, &z);//自動校準
while (1)
{
ADXL345_RD_XYZ(&x, &y,&z);
angx=ADXL345_Get_Angle(x,y,z,1);
angy=ADXL345_Get_Angle(x,y,z,2);
angz=ADXL345_Get_Angle(x,y,z,0);
USART1_SendString("\r\nAngx=");
USART1_SendNum(angx);
USART1_SendString("\tAngy=");
USART1_SendNum(angy);
USART1_SendString("\tAngz=");
USART1_SendNum(angz);
ADXL345_RD_XYZ(&x, &y,&z);
USART1_SendString("\tGx=");
USART1_SendNum2(-x*3.9);
USART1_SendString("\tGy=");
USART1_SendNum2(-y*3.9);
USART1_SendString("\tGz=");
USART1_SendNum2(z*3.9);
delay_ms(100);
}
}
復制代碼
歡迎光臨 ELEOK (http://m.afoofa.cn/)
Powered by Discuz! X5.0