风筝
发表于: 2020-4-8 21:00:00 | 显示全部楼层

在本篇文章中,我们使用Arduino开发板和脉搏传感器(Pulse Sensor)设计了一款心跳/脉搏/BPM速率监视器。脉搏传感器连接到Arduino开发板以监控心跳/脉搏/BPM速率,然后将结果显示在20 * 4 LCD显示屏上。您也可以使用1602或其他形式的LCD显示屏。

arduino-pulse-sensor.jpg


该传感器非常易于使用和操作。将手指放在传感器上方,它将通过测量毛细血管扩张引起的光变化来感应心跳。


脉搏传感器简介

pulse-sensor-lifeispreety.com_.png

脉搏传感器(Pulse Sensor)是一款适用于Arduino的即插即用心率传感器。想要将实时心率数据轻松整合到他们的项目中的学生、运动员、制造商以及游戏和移动开发人员都可以使用它,其本质是集成的光放大电路和降噪电路传感器。将脉搏传感器夹到您的耳垂或指尖,然后将其插入Arduino,即可随时读取心率。它还具有一个易于使用的Arduino演示代码。


脉搏传感器有三个引脚:VCC、GND和模拟引脚。

Pulse-sensor-Pin-out-1.png

该传感器模块的中心还有一个LED,可帮助检测心跳。在LED下方,有一个消除噪音的电路,该电路应能防止噪音影响读数。


心跳/脉搏/BPM速率监视器的电路连接图:

下面给出了将脉搏传感器与Arduino和LCD连接的电路图。只需按如下所示进行连接并上传代码。

pulse-Sensor.png


项目工作过程:

当心跳时,血液被运送通过人体,并被挤入毛细血管组织中。因此,这些毛细组织的体积增加。但是,在两次相应的心跳之间,毛细血管组织内部的体积减小了。心跳之间体积的这种变化会影响将通过这些组织传输的光量。这可以在微控制器的帮助下进行测量。


脉搏传感器模块带有一个有助于测量脉搏频率的灯。当我们将手指放在脉搏传感器上时,反射的光将根据毛细管血管内的血液量而变化。可以从脉搏传感器的输出中获取脉搏形式的光透射和反射变化。然后可以调节此脉搏以测量心跳,然后使用Arduino对其进行相应编程以读取为心跳计数。

IMG_20180504_134114.jpg


源代码:

下面给出了使用Arduino和脉搏传感器的心跳/脉搏/BPM速率监视器的源代码。按照电路图中的上方所示组装电路,然后在下面上传此代码。首先,您需要添加Pulse Sensor库文件。从这里下载库。然后只需上传此代码。

  1. #define USE_ARDUINO_INTERRUPTS true // Set-up low-level interrupts for most acurate BPM math.
  2. #include <PulseSensorPlayground.h> // Includes the PulseSensorPlayground Library.
  3. #include<LiquidCrystal.h>
  4. LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

  5. // Variables
  6. const int PulseWire = 0; // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
  7. const int LED13 = 13; // The on-board Arduino LED, close to PIN 13.
  8. int Threshold = 550; // Determine which Signal to "count as a beat" and which to ignore.
  9. // Use the "Gettting Started Project" to fine-tune Threshold Value beyond default setting.
  10. // Otherwise leave the default "550" value.

  11. PulseSensorPlayground pulseSensor; // Creates an instance of the PulseSensorPlayground object called "pulseSensor"
  12. void setup() {

  13. Serial.begin(9600); // For Serial Monitor
  14. lcd.begin(20,4);

  15. // Configure the PulseSensor object, by assigning our variables to it.
  16. pulseSensor.analogInput(PulseWire);
  17. pulseSensor.blinkOnPulse(LED13); //auto-magically blink Arduino's LED with heartbeat.
  18. pulseSensor.setThreshold(Threshold);

  19. // Double-check the "pulseSensor" object was created and "began" seeing a signal.
  20. if (pulseSensor.begin()) {
  21. Serial.println("We created a pulseSensor Object !"); //This prints one time at Arduino power-up, or on Arduino reset.
  22. lcd.setCursor(0,0);
  23. lcd.print(" Heart Rate Monitor");

  24. }
  25. }

  26. void loop() {

  27. int myBPM = pulseSensor.getBeatsPerMinute(); // Calls function on our pulseSensor object that returns BPM as an "int".
  28. // "myBPM" hold this BPM value now.
  29. if (pulseSensor.sawStartOfBeat()) { // Constantly test to see if "a beat happened".
  30. Serial.println("♥ A HeartBeat Happened ! "); // If test is "true", print a message "a heartbeat happened".
  31. Serial.print("BPM: "); // Print phrase "BPM: "
  32. Serial.println(myBPM); // Print the value inside of myBPM.
  33. lcd.setCursor(0,2);
  34. lcd.print("HeartBeat Happened !"); // If test is "true", print a message "a heartbeat happened".
  35. lcd.setCursor(5,3);
  36. lcd.print("BPM: "); // Print phrase "BPM: "
  37. lcd.print(myBPM);
  38. }
  39. delay(20); // considered best practice in a simple sketch.
  40. }
复制代码

跳转到指定楼层
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题 700 | 回复: 1482



手机版|

GMT+8, 2024-4-29 22:24 , Processed in 0.037417 second(s), 6 queries , Gzip On, MemCache On. Powered by Discuz! X3.5

YiBoard一板网 © 2015-2022 地址:河北省石家庄市长安区高营大街 ( 冀ICP备18020117号 )

快速回复 返回顶部 返回列表