Need help with if else statement for heart rate monitor project.


hi all. programming not strong point. know if else statement basic having trouble it. building heart monitor warning system. warning system consists of lcd, 1 red led , piezo buzzer. want if else statement - if heart rate less 140 lcd display regular heart rate, led , buzzer stay off. else lcd display warning! irregular heart rate. led , buzzer flash , beep @ same rate. here code have far. appreciated. thank in advance.

code: [select]

#include "wire.h"
#include "hrmi_funcs.h"
#include <liquidcrystal.h>


#define hrmi_host_baudrate 9600
#define hrmi_i2c_addr      127

#define max_in_buffsize 16

liquidcrystal lcd(12, 11, 5, 4, 3, 2);


char serinstr[max_in_buffsize];   // serial input string array
int numentries = 0;               // number of hr values request
int numrspchars;                  // number of response chars read
char i2crsparray[34];                // i2c response array, sized read 32 hr values
char hrmi_addr = hrmi_i2c_addr;   // i2c address use
int led = 13;



void setup()
{
// initialize i2c communication
hrmi_open();

// initialize serial interface
serial.begin(hrmi_host_baudrate);

lcd.begin(16, 2);
  pinmode(led, output);
  pinmode(9, output);


}


/*
* arduino main code loop
*/
void loop()
{
// request set of heart rate values
hrmicmdarg(hrmi_addr, 'g', (char) numentries);
     
// response hrmi
numrspchars = numentries + 2;
if (hrmigetdata(hrmi_addr, numrspchars, i2crsparray) != -1) {
   // send results on serial interface in ascii form
   serial.print("request "); serial.print(numentries); serial.print(" => ");
   for (int i=0; i<numrspchars; i++) {
     serial.print(i2crsparray[i], dec);
     serial.print(" ");
   }
   serial.println();
  }
   
// setup again
if (++numentries > 30)
     numentries = 0;
delay(1000);                  // delay 1 second between commands

if (???? < 140){
   digitalwrite(led, low);
   lcd.setcursor(0,1);
   lcd.print("regular heart rate");
}

else{
   lcd.setcursor(0,0);
   lcd.print("warning!");
   lcd.setcursor(0,0);
   lcd.print("irregular heart rate");
   digitalwrite(led, high);   // turn led on (high voltage level)
   delay(200);               // wait second
   digitalwrite(led, low);    // turn led off making voltage low
   delay(200);               // wait second
   analogwrite(9,128);
   delay(500);
   digitalwrite(9, low);
   delay(200);

}


thank you.

hi, problem experiencing code?
what ???? supposed mean?

tom........ :)


Arduino Forum > Using Arduino > Programming Questions > Need help with if else statement for heart rate monitor project.


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support