unsigned long requestCo2(int timeout) {
  Serial2.begin(9600);
  byte readCO2[] = {
    0xFE, 0X44, 0X00, 0X08, 0X02, 0X9F, 0X25
  };                             //Command packet to read CO2 (see app note)
  byte response[] = {
    0, 0, 0, 0, 0, 0, 0
  };                                                        //create an array to store CO2 response
  float valMultiplier = 1;
  int error = 0;
  long start1 = millis();
  long end1 = millis();
  while (!Serial2.available()) { //keep sending request until we start to get a response
    Serial2.write(readCO2, 7);
    delay(50);
    end1 = millis();
    if (end1 - start1 > timeout) {
      Serial_Print("\"error\":\"no co2 sensor found\"");
      Serial_Print(",");
      int error = 1;
      break;
    }
  }
  switch (error) {
    case 0:
      while (Serial2.available() < 7 ) //Wait to get a 7 byte response
      {
        timeout++;
        if (timeout > 10) {  //if it takes to long there was probably an error
#ifdef DEBUGSIMPLE
          Serial_Print_Line("I timed out!");
#endif
          while (Serial2.available()) //flush whatever we have
            Serial2.read();
          break;                        //exit and try again
        }
        delay(50);
      }
      for (int i = 0; i < 7; i++) {
        response[i] = Serial2.read();
#ifdef DEBUGSIMPLE
        Serial_Print_Line("I got it!");
#endif
      }
      break;
    case 1:
      break;
  }
  int high = response[3];                        //high byte for value is 4th byte in packet in the packet
  int low = response[4];                         //low byte for value is 5th byte in the packet
  unsigned long val = high * 256 + low;              //Combine high byte and low byte with this formula to get value
  Serial2.end();
  return val * valMultiplier;
}
// Main
int main()
{
	//Initialize the serial connection and pass it a desired baud rate.
	uart_init(9600);
	
	//Forever loop.
	while(1){
		
		//Call the Serial_Print function.
		Serial_Print("ALABTU!");
	}
}
// Main
int main()
{

	
	//Setup received data LED.
	DDRA |= (1 << PINA6);
	
	PORTA ^= (1 << PINA6);
	_delay_ms(250);
	PORTA ^= (1 << PINA6);
	
	//Initialize the serial connection and pass it a desired baud rate.
	uart_init(9600);
	
	//Forever loop.
	while(1){
		
		//Call the Serial_Print function.
		Serial_Print(receiveData);
		_delay_ms(400);
		receiveData = 0;
	}
}
void main(){ 
	
	Setup_IOports();
	atod_init();
	_delay(200);
	lcd_init();
	Serial_Init();
	Timer1_Init();
	enableInterrupt();

	clr_display();
	printf("Body Temperature ");
	position(2,1);
	printf(" and Heart Rate  ");
	__delay_ms(5000);
		
	clr_display();
	
	while(1){				
		switch (Mode){
			case  0 :			
				a2d_read();				
				__delay_ms(100);
				check_pc();
			break;
			case 1 :			
				Tx_Control = 1;
				Serial_Print( "*#DREQ=123" );
				Serial_NewLine();
				Tx_Control = 0;		
			break;
			case 2 :
				Tx_Control = 1;
				Serial_Print( "*#123=" );				
				Serial_NewLine();				
				Tx_Control = 0;	
			break;
			case 3 :
				Tx_Control = 1;				
				Serial_Print( "*#123=" );							
				Tx_Control = 0;	
				
				position(1,1);
				printf("Data request... ");
				position(2,1);
				printf("                ");
							
			break;
			case 4 :
				Tx_Control = 1;				
				Serial_NewLine();
				Tx_Control = 0;	
								
			case 5 :
				clr_display();			
			break;
			default:
			
			break;
		}	
	}
}