UTFT is stopped by digitalread?!

I have the UTFT program on the mega board with a 480x320 LCD, works great. But when I try to add my MH-Z14 code, the program stops in it's tracks.

// initialize the sensor pin as an input
pinMode(sensorPin, INPUT);
Serial.println("blaha 1");
// Read starting value for millis... (just some value)
Serial.println("blaha 2");
while(digitalRead(sensorPin) == LOW) {;}
Serial.println("blaha 3");
high = millis();
Serial.println("blaha 4");

the serialprint is used to locate where the program stops, and it stops right after "blaha 2" It doesnt matter if [u]while(digitalRead(sensorPin) == LOW) {;}[/u] is placed in setup or in the main loop, the program just stops when it gets to that. The MH-Z14 program works fine without the UTFT program, on serial terminal. Someone give me a hint please

I suggest you post your entire sketch and a link to the UTFT device, and how it is wired.

// UTFT_Demo_320x240 
// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// This program is a demo of how to use most of the functions
// of the library with a supported display modules.
//
// This demo was made for modules with a screen resolution 
// of 320x240 pixels.
//
// This program requires the UTFT library.
//

#include <UTFT.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];

// Set the pins to the correct ones for your development shield
// ------------------------------------------------------------
// Arduino Mega:
// -------------------
// Standard Arduino Mega/Due shield            : <display model>,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Mega      : <display model>,38,39,40,41
//
// Remember to change the model parameter to suit your display module!
UTFT myGLCD(CTE32HR,38,39,40,41);


const int sensorPin = 6;     // the number of the sensor pin
long low = 0;
long high = 0;
long lowTime = 0;
long highTime = 0;
long co2ppm = 0;

void setup()
{
  randomSeed(analogRead(0));
  
// Setup the LCD
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);
  myGLCD.clrScr(); 
  myGLCD.setColor(0, 0, 255);
  myGLCD.drawRect(0, 0, 319, 225);
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,318,224);
  myGLCD.setColor(0, 0, 255);
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.drawLine(159, 0, 159, 224);
  myGLCD.drawLine(1, 119, 318, 119);

  Serial.begin(9600);
  
  // initialize the sensor pin as an input
  pinMode(sensorPin, INPUT);
   Serial.println("blaha 1");
  // Read starting value for millis... (just some value)
   Serial.println("blaha 2");
while(digitalRead(sensorPin) == LOW) {;}
 Serial.println("blaha 3");
  high = millis();
   Serial.println("blaha 4");
  
}
 
void loop()
{

  myGLCD.setBackColor(64, 64, 64);
  myGLCD.setColor(255,255,0);
  myGLCD.print("Heating & turning control", CENTER, 227);             // text displayed at bottom
 
  delay (1000);

// Draw sin-, cos- and tan-lines  
  myGLCD.setColor(0,255,255);
  myGLCD.print("Sin", 5, 15);
  for (int i=1; i<478; i++)
  {
    myGLCD.drawPixel(i,159+(sin(((i*1.13)*3.14)/180)*95));
  }
  
}

So what should the while(digitalRead(sensorPin) == LOW) {;}do, except waiting for a pin 6 to go HIGH?

The pin you used as sensorpin (6) is used on my TFT as CLK for the SD-card

I dont know what pin 6 does, it comes from the MHZ14 program. My TFT uses the double pin row at the bottom of the board, how come it can use pin 6 for clock, when it is not even connected to it?

It appears to make a big difference changing pin from 6 to 8, and now the program works, i think. I'm confused.

MHZ14 program:

const int sensorPin = 8;     // the number of the sensor pin

long low = 0;
long high = 0;
long lowTime = 0;
long highTime = 0;
long co2ppm = 0;

void setup() {
  Serial.begin(9600);
  // initialize the sensor pin as an input
  pinMode(sensorPin, INPUT);
  // Read starting value for millis... (just some value)
while(digitalRead(sensorPin) == LOW) {;}
  high = millis();
}

void loop()
{
  while(digitalRead(sensorPin) == HIGH) {;}
  low = millis();
  highTime = low - high;
  
  while(digitalRead(sensorPin) == LOW) {;}
  high = millis();
  lowTime = high - low;
  co2ppm = 5000 * (highTime - 2) / ( highTime + lowTime - 4);

  
//    Serial.print("Hightime: ");
//    Serial.println(highTime,DEC);
//    Serial.print("Lowtime: ");
//    Serial.println(lowTime,DEC);
//    Serial.print("CO2  -  ");
//    Serial.print(lowTime * 2,DEC);
//    Serial.println(" ppm");    
    Serial.println(co2ppm); 
  }