|
這是一款采用AD8232作為心電監測芯片,它能在具有機械運動或遠程放置所產生干擾的情況之下,提取、放大、過濾得到極弱的生物電信號。采用Arduino ATmega328作為主控制芯片,LCD1602液晶屏作為顯示屏,使用鋰電池供電,并設計TP4056充電板,為保護電源電路,還為鋰電池供電增加了由DW01和8205A組成的電源保護電路,具有較好的便攜性和穩定性。通過與某米的手環對比,誤差在2-10次/min之間,想必是本人學藝不精的原因。程序如下:
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h> //引用I2C庫
- //設置LCD1602設備地址,這里的地址是0x3F,一般是0x20,或者0x27,具體看模塊手冊
- LiquidCrystal_I2C lcd(0x3F, 16, 2);
- unsigned int data[500], i, count, total[6], num, total1;
- int m, n = 0;
- void setup()
- { lcd.init(); // 初始化LCD
- lcd.backlight(); //設置LCD背景等亮
- Serial.begin(9600);
- lcd.setCursor(0, 0); //設置顯示指針
- lcd.print("HeartRate"); //輸出字符到LCD1602上
- }
- void loop()
- {
- if (n == 0)
- {
- delay(1000);
- }
- Serial.println(millis());
- for (i = 0; i < 500; i++)
- {
- data[i] = analogRead(A0);
- //Serial.println(data[i]);
- // send the value of analog input 0:
- //Wait for a bit to keep serial data from saturating
- delay(20);
- }
-
- for (i = 1; i < 500; i++)
- {
- m = abs(data[i] - data[i - 1]);
- // Serial.println(abs(m));
- if (abs(m) > 80)
- {
- count++;
- }
- }
- if (count >= 9 && count < 15)
- {
- n = count * 6;
- }
- if (count >= 17)
- {
- n = count * 3;
- }
- if (count < 9)
- {
- n = 60;
- }
- Serial.println(millis());
- Serial.println(n);
- count = 0;
- lcd.setCursor(0, 1);
- lcd.print(n);
- }
復制代碼 |
評分
-
查看全部評分
|