oiyela
Junior Member level 3
Hi, I am using a PIC16f877a microcontroller and using MPLAB ICD3 on hi-tech complier. the aim of my project is to find the heart rate. i have done the software to count the number of pulses coming in. the main problem i have now is i want to count the number of pulse for 15 seconds and then multiple it by 4 and display it. i have been struggling to do that. here is my code so far, what this code does is to display the counter on the LCD. what i need is to take this reading for 15 seconds and multiply it and display.
Another issue i have is that the count is starting from 0.1 instead of 1
Please If You Can Help Me With This.. This Will be Greatly Appreciated.
Code:
#include <htc.h>
#include "lcd.h"
#define _XTAL_FREQ 8000000
void pic_init(void);
main()
{
int heartrate[3];
int pulse;
pic_init(); //initialize PIC
lcd_init(); //initialize LCD
lcd_goto(0); //select first line
for(;;){
heartrate[0]=(int)(1* TMR0); //
lcd_goto(0); //select first line
lcd_string("BT = "); //
lcd_number(heartrate[0]/10,10,3); //
lcd_string(".");
lcd_number(heartrate[0]%10,10,1); //
lcd_string("BPM"); //
}}
void pic_init(void)
{
TMR0=0;
PORTD=0x00;
PORTA=0xFF;
CMCON = 0x07;
OPTION_REG = 0b00101000;
}
Please If You Can Help Me With This.. This Will be Greatly Appreciated.