亲,“电路城”已合并升级到更全、更大、更强的「新与非网」。点击查看「新与非网」

本网页已闲置超过3分钟,按键盘任意键或点击空白处,即可回到网页

基于Arduino的心跳监测器

发布时间:2021-05-03
分享到:

基于Arduino的心跳监测器

发布时间:2021-05-03
分享到:

通过Arduino制作心跳/脉搏监测设备,对心跳进行检查。

视频演示:

硬件部件:

  • Arduino UNO
  • 脉搏传感器
  • LCD(16*2)
  • 单圈电位器-10kΩ
  • 电阻-330Ω
  • LED-绿色
  • 跳线

电路图:

代码: 

// https://www.youtube.com/channel/UCaXI2PcsTlH5g0et67kdD6g  //
// HeartBeat / Pulse Monitoring Device //
// By MOHD SOHAIL //
#define USE_ARDUINO_INTERRUPTS true //为大多数准确的BPM数学设置低级中断
#include <PulseSensorPlayground.h> //包含PulseSensorPlayground库
#include <LiquidCrystal.h> //包括LiquidCrystal库

LiquidCrystal lcd(2, 3, 8, 9, 10, 11); //用“ lcd”初始化LiquidCrystal。lcd(RS,E,D4,D5,D6,D7)


const int PulseWire = A0; //PulseSensor PURPLE WIRE连接到ANALOG PIN 0
const int LED_3 = 13; //LED检测心脏何时跳动。LED连接到Arduino UNO的PIN 3
int Threshold = 550; //确定哪个信号“算作一个拍子”以及哪个信号可以忽略
                     //使用“入门项目”来微调阈值,使其超出默认设置
                     //否则保留默认的“ 550”值
//----------------------------------------在LCD上画“心”.
/*
                     heart4 heart5
                       ===   ===
                             
              = 00011 11000 00011 11000 =                      11 11       11 11   
               00111 11100 00111 11100                      111 111     111 111  
               01111 11110 01111 11110                     1111 1111   1111 1111 
               11111 11111 11111 11111                    11111 11111 11111 11111
      heart3   11111 11111 11111 11111   heart6           11111 11111 11111 11111
               11111 11111 11111 11111                    11111 11111 11111 11111
               11111 11111 11111 11111                    11111 11111 11111 11111
              = 01111 11111 11111 11110 =                    1111 11111 11111 1111 
                                               ------->
              = 00011 11111 11111 11000 =                      11 11111 11111 11   
               00001 11111 11111 10000                        1 11111 11111 1    
               00000 11111 11111 00000                          11111 11111      
      heart2   00000 11111 11111 00000   heart7                 11111 11111      
               00000 01111 11110 00000                           1111 1111       
               00000 00111 11100 00000                            111 111        
               00000 00011 11000 00000                             11 11         
              = 00000 00001 10000 00000 =                             1 1           
                             
                       ===   ===
                     heart1 heart8

*/

byte heart1[8] = {B11111, B11111, B11111, B11111, B01111, B00111, B00011, B00001};
byte heart2[8] = {B00011, B00001, B00000, B00000, B00000, B00000, B00000, B00000};
byte heart3[8] = {B00011, B00111, B01111, B11111, B11111, B11111, B11111, B01111};
byte heart4[8] = {B11000, B11100, B11110, B11111, B11111, B11111, B11111, B11111};
byte heart5[8] = {B00011, B00111, B01111, B11111, B11111, B11111, B11111, B11111};
byte heart6[8] = {B11000, B11100, B11110, B11111, B11111, B11111, B11111, B11110};
byte heart7[8] = {B11000, B10000, B00000, B00000, B00000, B00000, B00000, B00000};
byte heart8[8] = {B11111, B11111, B11111, B11111, B11110, B11100, B11000, B10000};
//----------------------------------------

int Instructions_view = 500; //等待时间以在LCD上显示指令的变量
                               
PulseSensorPlayground pulseSensor; //创建PulseSensorPlayground对象的实例,称为“ pulseSensor”


void setup() {   
  Serial.begin(9600);//以一定速度设置串行通信
  lcd.begin(16, 2); //初始化LCD屏幕的界面,并指定显示器的尺寸(宽度和高度)
  
  
  lcd.createChar(1, heart1);
  lcd.createChar(2, heart2);
  lcd.createChar(3, heart3);
  lcd.createChar(4, heart4);
  lcd.createChar(5, heart5);
  lcd.createChar(6, heart6);
  lcd.createChar(7, heart7);
  lcd.createChar(8, heart8);
  
 
  
  lcd.setCursor(0,0);
  lcd.print("Heart Beat/Pulse"); 
  lcd.setCursor(0,1);
  lcd.print(" Monitoring EIF ");
  delay(2000);

 
  pulseSensor.analogInput(PulseWire);   
  pulseSensor.blinkOnPulse(LED_3); //-->用心跳自动神奇地使Arduino的LED闪烁
  pulseSensor.setThreshold(Threshold);   

 
  if (pulseSensor.begin()) {
    Serial.println("We created a pulseSensor Object !"); //在Arduino上电或Arduino重置时打印一次
  }
  

  delay(2000);
  lcd.clear();
}

void loop() {
  int myBPM = pulseSensor.getBeatsPerMinute(); //在pulseSensor对象上调用函数,该函数将BPM作为“ int”返回。“ myBPM”现在保留此BPM值

 
  if (Instructions_view < 500) {
    Instructions_view++;
  }
  
  if (Instructions_view > 499) {
    lcd.setCursor(0,0);
    lcd.print("Put your finger ");
    lcd.setCursor(0,1);
    lcd.print(" on the sensor  "); 
    delay(1000);
    lcd.clear();
    delay(500);
  } 
  if (pulseSensor.sawStartOfBeat()) { //如果测试为“真”,则下面的条件将被执行
    Serial.println("  A HeartBeat Happened ! "); //打印一条消息“发生心跳”
    Serial.print("BPM: "); //打印短语“ BPM:”
    Serial.println(myBPM); //->在myBPM中打印值 

   lcd.setCursor(1,1);
    lcd.write(byte(1));
    lcd.setCursor(0,1);
    lcd.write(byte(2));
    lcd.setCursor(0,0);
    lcd.write(byte(3));
    lcd.setCursor(1,0);
    lcd.write(byte(4));
    lcd.setCursor(2,0);
    lcd.write(byte(5));
    lcd.setCursor(3,0);
    lcd.write(byte(6));
    lcd.setCursor(3,1);
    lcd.write(byte(7));
    lcd.setCursor(2,1);
    lcd.write(byte(8));
   
    lcd.setCursor(5,0);
    lcd.print("Heart Rate");
    lcd.setCursor(5,1);
    lcd.print(": ");
    lcd.print(myBPM);
    lcd.print(" ");
    lcd.print("BPM     ");
    
    Instructions_view = 0; 
  }
 
  delay(20); //在一个简单的草图中考虑了最佳实践
}

步骤:

1.拿取Arduino Uno,LCD显示,10K电位计,330欧姆电阻器,脉冲传感器,绿色LED,跳线和纸板的组件。

2.将LCD显示器焊接在PCB板上。

3.将LCD显示屏放在纸板箱上。

4.将Arduino放置在板上。

5.拿起脉冲传感器并将跳线连接到其上,然后将其放置在板上。

6.将绿色LED放在板上。

7.做标签。

8.从电路图进行连接。

9.上传Arduino代码。

10.用Arduino设备检查心跳。

加入微信技术交流群

技术交流,职业进阶

关注与非网服务号

获取电子工程师福利

加入电路城 QQ 交流群

与技术大牛交朋友

讨论