Problems with LCD changing text

Hello all,
I am using a 16X2 char. LCD for a project I am working on and it was working fine before. However it has started to malfunction a bit.
For Example, It is supposed to first read "Enter Length"
Once a length is entered it is supposed to say "Coating"
Then a series of other short messages.

However when I turn it on it will read Enter Length but will not show any other text throughout the program. I have included by code for reference.

Any advice is appreciated,
also i did not solder the wires on just kinda bent and crimped them around the leads of the LCD, I made sure they are not touching each other and it appears they are all touching the gold parts.

Thank you!

#include <Stepper.h>
#include <Keypad.h>
#include <LiquidCrystal.h>


// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(32,3,4,26,24,22);
// -------------------------KEYPAD------------------------
const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap

void setup()
{
  lcd.begin(16, 2);
  pinMode(motorPin1, OUTPUT);        // Actuator #1
  pinMode(motorPin2, OUTPUT);        // Actuator #2
  pinMode(motorPin3, OUTPUT);        // Actuator #3
  pinMode(motorPin4, OUTPUT);        // Actuator #4
  pinMode(Direction, OUTPUT); 
  pinMode(Sleep, OUTPUT);  
  pinMode(StepPin, OUTPUT);
  
  Serial.begin(9600);      // open the serial port at 9600 bps:
}



void loop()
{
  Count_2 = 0;
  digitalWrite(Sleep, LOW);               // Turn off power to stepper motor
  lcd.clear();
  lcd.setCursor(0, 0);                    // sets LCD cursor
  lcd.print("Enter Length: ");

  Keypad_func();                        // Go to Keypad Function

  Serial.println(Length);                // This is used for testing purposes
  
  Length_Converter();                    // Go to funtion to convert cm length to # of steps
  
  // *******************************
  //        COATING PROCESS BEGINS
  // *******************************

    lcd.clear();
    lcd.setCursor(0, 1);
    lcd.print("   Coating   ");
    delay (1000);

  lcd.setCursor(0, 0);                                // Sets LCD to print "Coating"
  lcd.print("    Coating     ");  

    Serial.print("Motor Initial Forward");        // Testing purposely only
    Serial.print("\n");                           // For Testing

    int DirectionToggle = 1;                // Just a Toggle for the Direction Flag
    digitalWrite(Direction,DirectionToggle);      // Sets up Direction of motor
    delay(250);
    digitalWrite(Sleep, HIGH);                    // Gives power back to the Stepper Motor
      
       for (int fwd = 0; fwd < 4620; fwd++)          // Move stepper motor a set distance to the funnel opening
        {
          digitalWrite(StepPin,HIGH);
          delayMicroseconds(1000);
          digitalWrite(StepPin,LOW);
          delayMicroseconds(1000);
        }

      delay(1);

  // *************************************************************
  //                   Begin Dispersion
  // *************************************************************
  
      for (Repeat = 0; Repeat < 11; Repeat ++)           // Loop 10 times moving forward and backwards 5 times each
      { 
        digitalWrite(motorPin1, HIGH);                   // Turn on Actuator 1
        digitalWrite(motorPin2, HIGH);                   // Turn on Actuator 2
        digitalWrite(motorPin3, HIGH);                   // Turn on Actuator 3
        digitalWrite(motorPin4, HIGH);                   // Turn on Actuator 4
        Dispersion();                                    // Call the Dispersion Function and read in the Length varaiable *note* need to call in length variable
      }


  // *************************************************************
  //                   Dispersion Finished
  // *************************************************************

    digitalWrite(motorPin1, LOW);                      // Turn off Actuator 1  
    digitalWrite(motorPin2, LOW);                      // Turn off Actuator 2  
    digitalWrite(motorPin3, LOW);                      // Turn off Actuator 3 
    digitalWrite(motorPin4, LOW);                      // Turn off Actuator 4 
    
    
    Serial.print("Motor Final Forward");                // For Testing
    Serial.print("\n");                                  // For Testing
  
      digitalWrite(Direction,DirectionToggle = 1);
        delay(100);
       for (int fwd = 0; fwd < 5030; fwd++)
        {
          digitalWrite(StepPin,HIGH);
          delay(1);
          digitalWrite(StepPin,LOW);
          delay(1);
        }

    digitalWrite(Sleep, LOW);
    Serial.print("Done Coating");                      // For Testing
    Serial.print("\n");                                // For Testing
    delay (500);
    lcd.setCursor(0, 0);
    lcd.print("Finished Coating");
    lcd.setCursor(0, 1);
    lcd.print("Press Any Button"); 
    delay (500);
    
    
    Restart(); 

    lcd.clear();
    delay (500);
    return;
}


void Restart()
{
  char key = kpd.getKey();                  // Read keypad value

  if (key != NO_KEY)
  {
      Serial.print("Return Steps: ");
      lcd.setCursor(0, 0);
      lcd.print("   Returning    ");
      digitalWrite(Sleep, HIGH);
      digitalWrite(Direction,DirectionToggle = 0);      
      ret_tot = 10030 + Length_1;      
      Serial.println(ret_tot);                      // For Testing
      Serial.print("\n"); 
      
      for (int ret = 0; ret < ret_tot; ret++)
          {
            digitalWrite(StepPin,HIGH);
            delay(1);
            digitalWrite(StepPin,LOW);
            delay(1);
          }
  }    
  else 
   {
     Restart();
   }
}

*I attached my entire script as well due to character limitations in the code

Code_4_8_15.ino (12.8 KB)

jjm10n:
also i did not solder the wires on just kinda bent and crimped them around the leads of the LCD, I made sure they are not touching each other and it appears they are all touching the gold parts.

Hmm.

This is a bit "retro"! :grinning:

Seems you have just re-discovered the "crystal set".

Sorry, this is the first code I have ever wrote in arduino. What would be a more "up to date" thing to do?

You really have to solder those connections.

Your 'actuators' may also be causing a problem as you will find if you search back through the forum. Look for cases where the complaint is weird characters after x seconds or something like that. Better wire placement and/or a capacitor across the LCD power pins frequently solves the problem.

Don

Thank you, Don.
I placed a capacitor at the positive of the LCD to ground and it seems to make it work a little better. However it still will not display once the next message. I have disconnected all power sources to the motors and still doesnt seem to make a difference. I will continue looking through the forums but any other advice would be fantastic!

In your code

void loop()
{   Count_2 = 0;
    digitalWrite(Sleep, LOW);               // Turn off power to stepper motor
    lcd.clear();
    lcd.setCursor(0, 0);                    // sets LCD cursor
    lcd.print("Enter Length: ");

  Keypad_func();                        // Go to Keypad Function

  Serial.println(Length);                // This is used for testing purposes

what is the result of your test? Are you getting Lengths as you expect?

I'm assuming you took the good advice about soldering. Until you do, you should expect unexpected results.

jjm10n:
I will continue looking through the forums but any other advice would be fantastic!

Did you understand my previous post? :astonished:

First, like others have said, you need to solder all connections to the lcd.

I don't have the hardware to debug your code, but I am not convinced that the problem is with the lcd instead of something related to the flow of the code.

I would suggest that you debug your code without using the lcd, but just use the Serial print to verify and validate what you are doing. Then when everything is working as desired, it will be simple to add the cursor control and lcd.print statements.

You have used lcd.println() statements many places in your code, but the lcd does not respond to the CR/LF commands. It will instead, print strange characters. Don't use lcd.println(), instead uses explict cursor control to the line you want and lcd.print().