51單片機讀取加速度傳感器LIS3DH數據并顯示在LCD12864上面
0.jpg (21.43 KB, 下載次數: 37)
下載附件
2018-4-12 04:27 上傳
單片機源程序如下:
- #include"reg51.h"
- #include"12864.h"
- #include "lis3dh_driver.h"
- #include <stdio.h>
- #include <intrins.h>
- #include<stdarg.h>
- #define uchar unsigned char
- #define uint unsigned int
- u16 a=1000;
- void lis3dhinit(void)
- {
- unsigned char response=0;
- response = LIS3DH_SetODR(LIS3DH_ODR_100Hz);
- //printf("設置 ODR:%d\r\n",response);
- response = LIS3DH_SetMode(LIS3DH_NORMAL);
- //printf("設置 MODE:%d\r\n",response);
- response = LIS3DH_SetFullScale(LIS3DH_FULLSCALE_2);
- //printf("設置 SCALE:%d\r\n",response);
- response = LIS3DH_SetAxis(LIS3DH_X_ENABLE | LIS3DH_Y_ENABLE | LIS3DH_Z_ENABLE);
- //printf("設置 ENABLE:%d\r\n",response);
- }
- void main()
- {
- AxesRaw_t ddata;
-
- Lcd_Init();
-
- //Show_number(0x80,a);
- delay(1000); //上電,等待穩定
- lis3dhinit();
-
-
-
-
- while(1)
- {
- LIS3DH_GetAccAxesRaw(&ddata); // 讀取函數在原來的庫函數上做了稍微調整
- delay(60000);
- delay(60000);
- delay(60000);
- delay(60000);
- delay(60000);
- delay(60000);
- delay(60000);
- delay(60000);
- Show_number(0x80,ddata.AXIS_X);
- Show_number(0x90,ddata.AXIS_Y);
- Show_number(0x88,ddata.AXIS_Z);
-
- //Show_number(0x98,a);
- }
-
- }
- ……………………
- …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
51單片機讀取加速度傳感器LIS3DH數據并顯示在LCD上面.rar
(129.75 KB, 下載次數: 172)
2018-4-11 22:33 上傳
點擊文件名下載附件
51單片機讀取加速度傳感器LIS3DH數據并顯示在LCD上面 下載積分: 黑幣 -5
|