LCD displaying only when reset

I setup the LCD using the LiquidCrystal library and wired based on the LadyAda tutorial page. When first wired up, it worked correctly. I updated some code, uploaded and now it doesn't display. I realized though that when I manually hit the reset button, it displays the text that should be on the screen during the reset routine. Once the program starts running again, it doesn't work. If I upload another sketch that doesn't use the LCD, the text comes up on the screen and stays there until I reupload an LCD script. I have tried the existing LiquidCrystal example scripts to no avail.

I'm running an Arduino Duevalinove with a 16x2 LCD (dubyadubyadubya.sparkfun.com/products/709).

Any direction would be great. Thanks!

Any direction would be great

Any code to check and a drawing of your LCD-pin setup would be great too :slight_smile:

#include <LiquidCrystal.h>

// Class
LiquidCrystal lcd( 7, 6, 5, 4, 3, 2 );

// Analog Pins
int pinThermistor = 5;
int pinStretch = 4;

// Digital Pins

// Constants
unsigned int rThermistor = 9880;
unsigned int rStretch = 4650;

// Variables
double a = 35.355;
double b = -.024862;

double temp = 0;
unsigned int histTimeStretch[30];
unsigned int histTimePeak[5];
unsigned int maxStretch;
unsigned int minStretch;
unsigned int midStretch;
unsigned long timeTemp = 0;
char dirStretch;
int respRate;
double periodAverage;

// Time
unsigned long timeThermistor = 1;
unsigned long timeStretch = 1;
unsigned long timeECG = 1;

unsigned int readThermistor = 1000;
unsigned int readStretch = 100;
unsigned int readECG = 32;


void setup()
{
  Serial.begin( 9600 );
  
  lcd.begin( 16, 2 );
  lcd.clear();
}

void loop()
{  
  // Thermistor routine
  if( millis()/readThermistor > timeThermistor )
  {
    timeThermistor += 1;
    
    // Read input
    int inputThermistor = analogRead( pinThermistor );
    
    // Calculate voltage
    double voltage = ((double)inputThermistor * 5 / 1024);
    
    // Calculate temperature from
    //  exponential curve
    temp = log( rThermistor / ( 1000 * a ) ) / b;
    Serial.print( "Temp: " );
    Serial.print( temp );
    Serial.print( " Analog Read: " );
    Serial.println( inputThermistor );
  }
  // Stretch sensor routine
  if( millis()/readStretch > timeStretch )
  {
    timeStretch += 1;
    
    // Move values forward one time slot
    for( int i = 29 ; i > -1 ; i-- )
      histTimeStretch[i] = histTimeStretch[i-1];
    
    // Read input
    histTimeStretch[0] = analogRead( pinStretch );
    
    maxStretch = 0;
    minStretch = 1000000;
    
    // Find min/max values
    for( int i = 0 ; i < 30 ; i++ )
    {
      if( histTimeStretch[i] < minStretch )
        minStretch = histTimeStretch[i];
      if( histTimeStretch[i] > maxStretch )
        maxStretch = histTimeStretch[i];
    }
    
    // Calculate midpoint
    midStretch = ( maxStretch + minStretch ) / 2;
    
    // Find which side of the midpoint
    //  the data starts on
    if( histTimeStretch[0] < midStretch )
      dirStretch = '-';
    else
      dirStretch = '+';
      
    // Determine when values cross midpoint
    for( int i = 0 ; i < 30 ; i++ )
    {
      if( dirStretch == '-' )
        if( histTimeStretch[i] > midStretch )
        {
          dirStretch = '+';
          
          for( int j = 4 ; j > -1 ; j++ )
          {
            histTimePeak[i] = histTimePeak[i-1];
          }
          
          histTimePeak[0] = millis();
        }
      else
        if( histTimeStretch[i] < midStretch )
        {
          dirStretch = '-';
          
          for( int j = 4 ; j > -1 ; j++ )
          {
            histTimePeak[i] = histTimePeak[i-1];
          }
          
          histTimePeak[0] = millis();
        }
    }
    
    periodAverage = 0;
    for( int i = 0 ; i < 4 ; i++ )
      periodAverage += histTimePeak[i] - histTimePeak[i+1];
      
    periodAverage /= 4;
    
    respRate = 1/periodAverage;
    Serial.print( "RespRate: " );
    Serial.println( respRate );
  }
  // ECG routine
  if( millis()/readECG > timeECG )
  {
    timeECG += 1;
  }
  
  // Output to LCD
  
  lcd.setCursor( 0, 0 );
  lcd.print( "Temp: " );
  lcd.print( temp );
  lcd.setCursor( 0, 1 );
  lcd.print( "Resp Rate: " );
  lcd.print( respRate );
}

As for the pins, I have them wired as per the LadyAda tutorial including the 10k pot for contrast (Arduino Tutorial - connecting a parallel LCD). The only change I made due to physical limitations is that lcd14->digital 2, lcd13->digital 3, lcd12->digital 4, lcd11->digital 5, lcd6->digital 6, lcd4->digital 7.

That’s:
DB7->dig2
DB6->dig3
DB5->dig4
DB4->dig5
EN->dig6
RS->dig7

I have to assume that your DB’s chart is all wrong.

Try changing
LiquidCrystal lcd( 7, 6, 5, 4, 3, 2 ); // Current config

To:
LiquidCrystal lcd( 7, 6, 2, 3, 4, 5); // Option A

or

LiquidCrystal lcd( 6, 7, 2, 3, 4, 5); // Option b

or

LiquidCrystal lcd( 6, 7, 5, 4, 3, 2 ); // Option C << I think this is the right one because your code reacts on Reset.

Solution, provided by your friend René Descartes.