Place your index finger gently on the sensor, and you will see the LED indicator light flashing with your heartbeat. The arteries in the fingertips of the human body are well developed. When the arteries contract and relax periodically with the heart, the blood volume in the blood vessels will also change.
The above is the schematic diagram of the acquisition part. Please go to http://www.51hei.com/bbs/dpj-22525-1.html to download the complete set of production materials . The following is the source code of the microcontroller part of the heart rate meter.
/*
Project: Measuring heart rate through fingertip
Copyright @ Rajendra Bhatt
January 18, 2011
PIC16F628A at 4.0 MHz external clock, MCLR enabled
*/
sbit IR_Tx at RA3_bit; sbit
DD0_Set at
RA2_bit;
sbit DD1_Set at RA1_bit
;
sbit
DD2_Set at
RA0_bit
; ------------- Function to Return mask for common anode 7-seg. display
unsigned short mask (unsigned short num) {
switch (num) {
case 0 : return 0xC0;
case 1 : return 0xF9 ;
case 2 : return 0xA4;
case 3 : return 0xB0;
case 4 : return 0x99;
case 5 : return 0x92;
case 6 : return 0x82;
case 7 : return 0xF8;
case 8: return 0x80;
case 9: return 0x90;
} //case end
}
void delay_debounce(){
Delay_ms(300);
}
void delay_refresh(){
Delay_ms(5);
}
void countpulse(){
IR_Tx = 1;
delay_debounce();
delay_debounce();
TMR0=0;
Delay_ms(15000); // Delay 1 Sec
IR_Tx = 0;
pulsecount = TMR0;
pulserate = pulsecount*4;
}
void display(){
DD0 = pulserate%10;
DD0 = mask(DD0);
DD1 = (pulserate/10)%10;
DD1 = mask(DD1);
DD2 = pulserate/100;
DD2 = mask (DD2);
for ( i = 0; i<=180*j; i++) {
DD0_Set = 0;
DD1_Set = 1
; DD2_Set = 1;
PORTB = DD0;
delay_refresh();
DD0_Set = 1;
DD1_Set = 0;
DD2_Set = 1;
PORTB = DD1;
delay_refresh();
DD0_Set = 1;
DD1_Set = 1;
DD2_Set = 0;
PORTB = DD2;
delay_refresh();
}
DD2_Set = 1;
}
void main() {
CMCON = 0x07; // Disable Comparators
TRISA = 0b00110000; // RA4/T0CKI input, RA5 is I/P only
TRISB = 0b10000000; // RB7 input, rest output
OPTION_REG = 0b00101000; // Prescaler (1 :1), TOCS =1 for counter mode
pulserate = 0;
j = 1;
display();
do {
if(!start){
delay_debounce();
countpulse();
j= 3;
display();
}
} while( 1); // Infinite loop
}
Previous article:How to customize characters for LCD1602
Next article:Program to realize multi-machine communication between single chip microcomputer and PC
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- CC2640 debugging experience: adding serial port
- 【NXP Rapid IoT Review】+ GUI Usage
- N32WB452 asked: Does N32WB452 have a basically complete ported RT-Thread development kit?
- IoT Gateways – A Simple Guide to the Internet of Things
- [Anxinke UWB indoor positioning module NodeMCU-BU01] No.004-Distance measurement test, evaluation completed
- [Bluesun AB32VG1 RISC-V evaluation board] IDE installation and use
- It's New Year's Eve soon. I wish you all a happy New Year.
- 【DIY Creative LED】Add touch button and install it on LED lamp
- [RISC-V MCU CH32V103 Review] - 2: Making an LED flash is not easy
- SensorTile.box uses air pressure sensors to analyze environmental changes