本設(shè)計(jì)由STM32F103C8T6單片機(jī)核心板電路+ADXL345傳感器電路+心率傳感器電路+溫度傳感器+lcd1602電路組成。
1、通過(guò)重力加速度傳感器ADXL345檢測(cè)人的狀態(tài),計(jì)算出走路步數(shù)、走路距離和平均速度。
2、通過(guò)心率傳感器實(shí)時(shí)檢測(cè)心率,通過(guò)溫度傳感器檢測(cè)溫度。
3、lcd1602實(shí)時(shí)顯示步數(shù)、距離和平均速度、心率以及溫度值。
源碼:
stm32 adxl345完整codes.7z
(200.08 KB, 售價(jià): 3 E幣)
基于STM32的智能運(yùn)動(dòng)手環(huán)原理圖:
sch原理圖.zip
(98.08 KB, 售價(jià): 3 E幣)
3.png (17.84 KB)
下載附件
2020-8-2 13:39 上傳
1.png (88.72 KB)
下載附件
2020-8-2 13:39 上傳
2.png (41 KB)
下載附件
2020-8-2 13:39 上傳
部分源碼片段:
- #include "led.h"
- #include "delay.h"
- #include "sys.h"
- #include "usart.h"
- #include <stdio.h>
- #include "timer.h"
- #include "key.h"
- #include "exti.h"
- #include "adxl345.h"
- #include "lcd1602.h"
- #include "ds18b20.h"
- unsigned char ReadAdxl345; //定時(shí)讀取adxl345數(shù)據(jù)
- unsigned char ErrorNum=0; //記錄錯(cuò)誤次數(shù)
- unsigned char CheckNum=0; //檢測(cè)次數(shù)
-
- char dis0[16];//液晶數(shù)組顯示暫存
- char dis1[35];
- unsigned int xlTab[5];//心率數(shù)組
- unsigned char count=0; //心率濾波計(jì)數(shù)
- unsigned int xinLater=0;// 心率延時(shí)處理
- unsigned int xinLv =0; //心率值
- unsigned int BuShu=0;//步數(shù)
- unsigned int Normal_num=0; //正常次數(shù)
- unsigned int Error_num=0; //傾斜次數(shù)
- unsigned int disBuShu = 0; //顯示步數(shù)
- float disJuLi = 0;//顯示距離
- float temperature; //溫度
- unsigned char readTemp = 0; //讀取溫度標(biāo)志
- int main(void)
- {
- delay_init(); //延時(shí)函數(shù)初始化
- uart_init(9600); //串口初始化為9600
- TIM3_Int_Init(49,7199);//50ms
- EXTIX_Init(); // 初始化外部中斷
- LED_Init(); //初始化與LED連接的硬件接口
- KEY_Init(); //初始化按鍵
- Lcd_GPIO_init(); //初始化lcd引腳
- Lcd_Init(); //初始化lcd屏幕
- delay_ms(200);
-
- Init_ADXL345();
- if(Single_Read_ADXL345(0X00)==0xe5)
- {
- delay_ms(5);
- }
- else
- {
- delay_ms(3);
- }
-
- while(1)
- {
- if(ReadAdxl345== 1) //定時(shí)讀取adxl345數(shù)據(jù)
- {
- ReadAdxl345= 0;
- ReadData_x(); //三軸檢測(cè)函數(shù)
- CheckNum++;
- if((temp_Y>450)||(temp_Y<-450)) //查看正常次數(shù)
- {
- Normal_num++; //正常次數(shù)++
- }
- else
- {
- Error_num++;//傾斜次數(shù)
- }
- if((Error_num!=0)&&(Normal_num!=0))//檢測(cè)到步數(shù)
- {
- BuShu++; //步數(shù)脈沖量++
- Error_num=0; //清除一個(gè)周期檢測(cè)
- Normal_num=0;
- }
- }
-
- if(disFlag==1) //顯示標(biāo)志
- {
- disFlag = 0;
- readTemp++; //定時(shí)計(jì)數(shù)
- if(readTemp >= 8)//約800ms處理一次數(shù)據(jù) 溫度
- {
- readTemp =0;//重新計(jì)數(shù)
- temperature=(float)DS18B20_Get_Temp()/10; //縮小10倍為實(shí)際值
- }
-
- disBuShu = BuShu/2; //顯示步數(shù)
- disJuLi = disBuShu*0.45;//顯示距離
-
- sprintf(dis0,"X:%03d/min %4.1f C",xinLv,temperature);//打印
- Lcd_Puts(0,0,(unsigned char *)dis0); //顯示
- Lcd_1Put(14,0,0xdf);//顯示符號(hào)
- sprintf(dis1,"BS:%03d JL:%4.1fm ",disBuShu,disJuLi);//打印
- Lcd_Puts(0,1,(unsigned char *)dis1); //顯示
-
- }
- }
- }
復(fù)制代碼
【必讀】版權(quán)免責(zé)聲明
1、本主題所有言論和內(nèi)容純屬會(huì)員個(gè)人意見(jiàn),與本論壇立場(chǎng)無(wú)關(guān)。2、本站對(duì)所發(fā)內(nèi)容真實(shí)性、客觀性、可用性不做任何保證也不負(fù)任何責(zé)任,網(wǎng)友之間僅出于學(xué)習(xí)目的進(jìn)行交流。3、對(duì)提供的數(shù)字內(nèi)容不擁有任何權(quán)利,其版權(quán)歸原著者擁有。請(qǐng)勿將該數(shù)字內(nèi)容進(jìn)行商業(yè)交易、轉(zhuǎn)載等行為,該內(nèi)容只為學(xué)習(xí)所提供,使用后發(fā)生的一切問(wèn)題與本站無(wú)關(guān)。 4、本網(wǎng)站不保證本站提供的下載資源的準(zhǔn)確性、安全性和完整性;同時(shí)本網(wǎng)站也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的損失或傷害。 5、本網(wǎng)站所有軟件和資料均為網(wǎng)友推薦收集整理而來(lái),僅供學(xué)習(xí)用途使用,請(qǐng)務(wù)必下載后兩小時(shí)內(nèi)刪除,禁止商用。6、如有侵犯你版權(quán)的,請(qǐng)及時(shí)聯(lián)系我們(電子郵箱1370723259@qq.com)指出,本站將立即改正。
|