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
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- Europe's three largest chip giants re-examine their supply chains
- Breaking through the intelligent competition, Changan Automobile opens the "God's perspective"
- The world's first fully digital chassis, looking forward to the debut of the U7 PHEV and EV versions
- Design of automotive LIN communication simulator based on Renesas MCU
- When will solid-state batteries become popular?
- Adding solid-state batteries, CATL wants to continue to be the "King of Ning"
- The agency predicts that my country's public electric vehicle charging piles will reach 3.6 million this year, accounting for nearly 70% of the world
- U.S. senators urge NHTSA to issue new vehicle safety rules
- Giants step up investment, accelerating the application of solid-state batteries
- Guangzhou Auto Show: End-to-end competition accelerates, autonomous driving fully impacts luxury...
- Application of 12-bit D/A converter MAX531 in high-frequency switching rectifier module
- 17 kinds of component PCB packaging illustrations, beautiful
- MV-VS Series 1394 High Resolution Industrial Digital CCD Camera
- High-speed electronic switches
- Decoding ZigBee IP specifications: Smart energy sensor networks are more reliable
- Negative feedback delay problem of power amplifier
- Wireless Mesh Network Technology Foundation and Application
- Parallel I/O Port Programming
- Coreless (standard low voltage) DC servo motor
- 281x DSP does not require an emulator, serial port flash programming method