I tried changing it to int, but it did not work.
This is the loop where I draw the ekg and update temp.
unsigned int weiterverarbeitung(volatile unsigned char high_byte, volatile unsigned char low_byte)
{
unsigned int value = ((high_byte&0x0f)*256)+(low_byte);
return(value);
}
unsigned long Start, Finished = 0;
float heart_rate = 0;
float RR_interval = 0;
unsigned int Delay = 9;
int thisdot = 0;
int prevdot = 0;
void loop() {
// this is the temp code that messes the ekg reading
int reading = analogRead(tempsensorPin); //pin assigned earlier
int temp = (((reading * 5)-.6)*100)/1024;
GLCD.print(temp);
for(int l=0; l<GLCD.Width; l++)
{
Finished = 0;
unsigned int val = weiterverarbeitung(TXBuf[4],TXBuf[5]); //extracting channel bytes
unsigned int y = map (val, 0, 1023,200,0)-50; //scaled
thisdot = y;
int slope = prevdot - thisdot;
// Writes hear rate if slope is greater than 3
if (slope >= 3 && Start == 0)
{Start = millis();}
else if(slope >= 3 && Start > 0)
{Finished = millis();
RR_interval = Finished - Start;
if(RR_interval>=150) //refractory period
{RR_interval = RR_interval/1000; //convert to seconds
heart_rate = 60/RR_interval;}
Start = 0;
}
if(heart_rate<220)
{GLCD.CursorToXY(0, 4);
GLCD.SelectFont(Wendy3x5);
GLCD.print("HEART RATE");
GLCD.CursorToXY(5, 15);
GLCD.SelectFont(System5x7);
GLCD.print(heart_rate);
}
//Draw graph
GLCD.SetDot(l,y,BLACK);
delay(Delay);
prevdot = thisdot;
thisdot = 0;
slope = 0;
}
GLCD.ClearScreen();
}