Go Down

Topic: LCD 20x 4 only shows white box on line 1 and 3 (Read 2286 times) previous topic - next topic

Eurnis123

Hello all, I need ur help....

 just now I go test the motor ...everything fine yet my lcd cant display the text, at 1st can see got text yet hardly see coz all white ... now my lcd only show line 1 and 3 with white box and no character anymore... my lcd is 20 x 4 (2004A)...with blue light display...

yet i still can press 1 by keypad n key in time n speed the motor will run n stop at time i set( the program code stills can run with the input ) yet LCD dint show the text... what is the problem of LCD or the connection?? below is my lcd pin connection....

VSS- Ground
VDD- 5V
Vo- Ground
RS-A0
RW-Ground
E-A1

D4-A2
D5-A3
D6-A4
D7-A5

PaulS

We don't know what kind of LCD you have connected to those pins, so that information is useless.

A diagram is far easier to understand.

We don't know what code you have running, or how the back light and/or contrast are adjusted.

So, we really can't help you.
The art of getting good answers lies in asking good questions.

sterretje

#2
May 21, 2016, 03:49 pm Last Edit: May 21, 2016, 03:52 pm by sterretje
I think this is the schematic (Eurnis is aware of the incorrect position of the flayback diode).



Posting the code is advisable as this is a new thread. One thing I noticed is that you don't have a potentiometer to adjust the brightness.

Please post your current code and double check your wiring. Did this problem start after you connected the motor? Or was it always a problem?

How is the motor powered? From the same power supply as the Uno? What kind of power supply?
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Eurnis123

Hi all n hai sterretje, thank you helping me clarify my problem more clear to all in this forum....

The code I used is the code u write it to me... i think is the lcd got problem

and sterretje, my lcd problem is  the problem after I connected to motor, last time i tested it with LED and the LCD still show  reading text  that i could key in values  and show the LED light on and off... now although i disconnect the motor , the LCD still show white box in line 1 and 3.... my LCD is 20x4( model 2004A) ... the connection of pins , i checked many time n i tested it with reconnect and reconnect again n again many time, still the LCD shows white box in Line 1 n 3... what is the problem??

the connection of some pins is (not shown on the schematic diagram)

VSS- Ground
VDD- 5V
Vo- Ground

and my motor is 6v DC motor n supply power using the arduino by the connection of breadboards.

Eurnis123

#4
May 21, 2016, 06:15 pm Last Edit: May 21, 2016, 06:28 pm by Eurnis123
 :(  i try all other connection pins of the program code, the LCD stills showing white box within the line 1 and 3....what is the problem?? my LCD broken or ??  ... so frustracting... headache already, coz trying from 6pm till now is 12:16am ...T.T   

Eurnis123

 :(  the image of the LCD with white box shown only on line 1 n 3... no text display

sterretje

Please post the code; others might not be able to find it.

Feeding the motor from the Arduino 5V might not be the best idea; did you fix the diode?

I can't really help remotely with hardware problems.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Eurnis123

 :(  the motor is get rid from boards n test the LCD, the results is same... i got used other power supply n fixed the diode... n now problem is the LCD display stills show white box on line 1 n 3 even i remove the motor n try other basic codes , the results still same.. what is the problem?  :(

Code: [Select]


#define HASKEYPAD
#define LCD20X4

#define ST_DISPLAY_MAINMENU 0
#define ST_WAIT 1
#define ST_SETSPEED 2
#define ST_SETTIMING 3

// options to control the motor
#define MOTOR_CONTINUE 0
#define MOTOR_START 1
#define MOTOR_FORCESTOP 2

int motorPin =3 ;

#include <LiquidCrystal.h>;
#ifdef HASKEYPAD
#include <Keypad.h>;

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};

byte rowPins[ROWS] = {10, 9, 8, 7}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {13, 12, 11}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
#else
#define NO_KEY 0
#endif

// initialize the library with the numbers of the interface pins
#ifdef LCD20X4
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);
#else
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
#endif


// the state of our application; start with main menu display
byte currentState = ST_DISPLAY_MAINMENU;

// speed and timing variables
// both are global so we can display them in the main menu
int theSpeed = 0;
long theTiming = 0;


void setup() {
  Serial.begin(9600);

  pinMode(motorPin, OUTPUT);
  // set up the LCD's number of columns and rows:
#ifdef LCD20X4
  lcd.begin(20, 4);
  Serial.println("20x4 display");
#else
  lcd.begin(16, 2);
  Serial.println("16x2 display");
#endif
}

void loop()
{
  // single key from keypad
  char key;
  // text from keypad
  char *text;

  // let the motor do what it was doing
  runMotor(MOTOR_CONTINUE);

  //Serial.print("Speed: "); Serial.println(theSpeed);

  switch (currentState)
  {
    case ST_DISPLAY_MAINMENU:
      // display main menu
      displayMenu();
      // switch to wait state
      currentState = ST_WAIT;
      break;
    case ST_WAIT:
      // get key
      key = getKeyWithEcho();
      // if speed setting selected
      if (key == '1')
      {
        // display speed 'menu'
        displaySpeedMenu();
        // change to state where user can enter speed
        currentState = ST_SETSPEED;
      }
      // if timing setting selected
      if (key == '2')
      {
        // display 'timing' menu
        displayTimingMenu();
        // change to state where user can enter timing
        currentState = ST_SETTIMING;
      }
      // Note: state does not change if entry is not '1' or '2'
      break;
    case ST_SETSPEED:
      // get the text entered on the keypad
      text = getKeypadText();
      // if text complete
      if (text != NULL)
      {
        // if user did enter a speed
        if (text[0] != '\0')
        {
          theSpeed = atoi(text);
        }
        currentState = ST_DISPLAY_MAINMENU;
      }
      break;
    case ST_SETTIMING:
      // get the text entered on the keypad
      text = getKeypadText();
      // if text complete
      if (text != NULL)
      {
        // if user did enter a speed
        if (text[0] != '\0')
        {
          theTiming = atoi(text);
          runMotor(MOTOR_START);
        }
        currentState = ST_DISPLAY_MAINMENU;
      }
      break;
  } // end_of_switch

}


/*
  display a title on the first line of the display; it always clears the LCD
*/
void displayTitle()
{
  // clear the lcd
  lcd.clear();

  // print the project title on the first line
  lcd.setCursor(0, 0);
  lcd.print("Speed controller");
}

/*
  display main menu
*/
void displayMenu()
{
  // current line where to write on LCD; every time that we write, currentLine will be incremented
  byte currentLine = 0;
  // text buffer for 20 characters and string terminator
  char textbuffer[21];

  // display the title on the first line and update currentLine
  displayTitle();
  currentLine = 1;

  // print the current settings on the second line
  lcd.setCursor(0, currentLine++);
  sprintf(textbuffer, "S = %d, T = %d", theSpeed, theTiming);
  lcd.print(textbuffer);

#ifdef LCD20X4
  // print the first menu option on the third line
  lcd.setCursor(0, currentLine++);
  lcd.print("1 Set speed");

  // print the second menu option on the fourth line
  lcd.setCursor(0, currentLine++);
  lcd.print("2 Set time");
#endif
}

/*
  display a 'menu' where the user can enter a speed
*/
void displaySpeedMenu()
{
  // display the title on the 1st line
  displayTitle();
#ifdef LCD20X4
  // display additional info on 3rd line
  lcd.setCursor(0, 2);
  lcd.print("#Finish, *Cancel");
#endif
  // prompt user to set speed (2nd line)
  lcd.setCursor(0, 1);
  lcd.print("Set speed: ");
}

/*
  display a 'menu' where the user can enter a timing
*/
void displayTimingMenu()
{
  // display the title on the 1st line
  displayTitle();
#ifdef LCD20X4
  // display additional info on 3rd line
  lcd.setCursor(0, 2);
  lcd.print("#Finish, *Cancel");
#endif
  // prompt user to set speed (2nd line)
  lcd.setCursor(0, 1);
  lcd.print("Set time: ");
}



Eurnis123

continues code...

Code: [Select]

/*
  get a keystroke from the keypad
  echo the key that was pressed to the LCD
  the echo will be on the current position of the LCD
  returns
    the key that was pressed or NO_KEY
*/
char getKeyWithEcho()
{
  // read a key
#ifdef HASKEYPAD
  char key = keypad.getKey();
#else
  char key;
  if (Serial.available() > 0)
  {
    key = Serial.read();
  }
  else
  {
    key = NO_KEY;
  }

#endif
  // if no key pressed
  if (key != NO_KEY)
  {
    // for debugging, output to serial monitor
    Serial.print("Key: "); Serial.println(key);
    // display on current position of LCD
    lcd.print(key);
  }
  return key;
}

/*
  get a text from the keypad (max 20 characters)
  '#' finishes the entry of data
  '*' cancels the entry of data
  returns
    NULL if not complete
    empty text if canceled
    entered tet (might be empty)
*/
char *getKeypadText()
{
  // a buffer for 20 keypresses and one
  static char keypadbuffer[21];
  // index in above buffer
  static char index = 0;

  // read a key
  char key = getKeyWithEcho();
  // if nothing pressed
  if (key == NO_KEY)
  {
    // indicate no complete data
    return NULL;
  }
  // if 'cancel' key
  if (key == '*')
  {
    // reset index
    index = 0;
    // create empty text
    keypadbuffer[index] = '\0';
    // return text
    return keypadbuffer;
  }
  // if 'enter' key
  if (key == '#')
  {
    // add a string terminator
    keypadbuffer[index] = '\0';
    // reset index for next time
    index = 0;
    // return the text
    Serial.println(keypadbuffer);
    return keypadbuffer;
  }
  // check for buffer overflow
  if (index >= sizeof(keypadbuffer))
  {
    // add a string terminator
    keypadbuffer[sizeof(keypadbuffer) - 1] = '\0';
    // reset index for next time
    index = 0;
    // return the text
    return keypadbuffer;
  }

  // add the character to the buffer
  keypadbuffer[index++] = key;

  // indicate that text is not complete
  return NULL;
}


/*
  starts or stops the motor or runs the motor for a given time
  parameter
    option: option to control motor
    MOTOR_FORCESTOP: force an (emergency) stop; oberrides any other options
    MOTOR_START: if not started, start it; if already started, it's ignored
    for any other option value, motor keeps on doing what it was doing
*/
void runMotor(byte options)
{
  // the 'time' that the motor started running
  static unsigned long motorRunStarttime = 0;

  // if FORCESTOP received
  if ((options & MOTOR_FORCESTOP) == MOTOR_FORCESTOP)
  {
    // for debugging
    Serial.println("FORCESTOP received");
    // stop the motor
    analogWrite(motorPin, 0);
    // reset start 'time'
    motorRunStarttime = 0;
    // nothing more to do
    return;
  }

  // if START received and motor not started yet
  if ((options & MOTOR_START) == MOTOR_START && motorRunStarttime == 0)
  {
    // for debugging
    Serial.println("START received while motor was not running");
    Serial.print("Speed: "); Serial.println(theSpeed);
    Serial.print("Timing: "); Serial.println(theTiming);

    // set the start 'time'
    motorRunStarttime = millis();
    // display the start time
    Serial.print("Time: "); Serial.println(motorRunStarttime);
  }

  // if the motor has run for the specified duration
  if (millis() - motorRunStarttime >= (theTiming * 1000UL))
  {
    // inform the user that motor has stopped
    if (motorRunStarttime != 0)
    {
      Serial.println("Motor stopped");
      Serial.print("Time: "); Serial.println(millis());
    }
    // stop the motor;
    analogWrite(motorPin, 0);
    // reset the start 'time'
    motorRunStarttime = 0;
  }
  else
  {
    // set the motor speed
    if (theSpeed >= 0 && theSpeed <= 255)
    {
      analogWrite(motorPin, theSpeed);
    }
  }
}

Eurnis123

 :(  i juz finish my all assignments n now need busy with final exams... left this make me big head project, I wanna ask all is my LCD broken? I dnt think my connection wrong, i check n recheck again many time,,,,  :(  :(  :(

Eurnis123

i saw many ppl got same problem with me with white box in line 1 n 3 , yet detail solution not clearly said.. i hard to catch out what they want said... kindly need all ur help...  :(

thank u...

sterretje

If you found information about the same problem, you should post links.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Eurnis123

https://www.element14.com/community/thread/24273/l/arduino-i2c-display?displayFullThread=true

http://forum.arduino.cc/index.php?topic=213152.0


Need help, i not really understand.... the point is my LCD broken? need buy new one or? Thank... ;(

cattledog

#13
May 22, 2016, 08:29 am Last Edit: May 22, 2016, 08:32 am by cattledog
Code: [Select]
Vo- Ground

I think you would do better with a resistance of between 470 and 2K ohms between Vo(lcd pin 3) and ground. The best contrast is usually where the blocks just disappear. Many people use a 10K potentiometer connected to 5v and gnd with the wiper connected to pin3(Vo), but that is not actually required.

If the display was working and now it is not, I recommend that you go back to running a simple lcd example sketch with no keypad or motor attached. At this point, the main issue is determining if somehow you have damaged the display.

If you can't get back to where you were, start a new thread in the display section of the forum. You can mentioned that the display was working until a motor was hooked up, but for now, the motor and keypad code are not relevant.  Just post your simple lcd test sketch which is not working.

You should post clear photographs of your actual wiring, photographs of the contrast level (white blocks or black ones), and the simple, lcd test sketch you are running.



 

Eurnis123

HI all n hai cattledog, thx for ur responds...
T.T

I have the same problem with this guys, yet i dunno understand their solution, pls help me .... T.T T.T T.T

link is  http://arduino.stackexchange.com/questions/17402/what-could-make-an-lcd-stop-working-permanently-after-being-connected-for-5-seco



thx if u can help me... ;(

Go Up