Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function that calculates heart beats per minute. The current code gets 10 pulse samples and averages them out. Change the code so it
Write a function that calculates heart beats per minute. The current code gets 10 pulse samples and averages them out. Change the code so it calculates heart beats per minute.
#include "msp430g2253.h" // Variables int adc[10] = {0}; //Sets up an array of 10 integers and zero's the values int avg_adc = 0; // Function prototypes void adc_Setup(); void adc_Sam10(); //Samples 10 values void main() { WDTCTL = WDTPW + WDTHOLD; // Stop WDT adc_Setup(); // Fucntion call for adc_setup while(1) { long adctot = 0; adc_Sam10(); // Fills adc[10] array with pulse readings // Add all the sampled data and divide by 10 to find average int i = 0; for(i = 0; i <= 9; i++){ adctot = adctot + adc[i]; } avg_adc = adctot/50; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started