Go Down

Topic: LCD Keypad Shield (Read 6860 times) previous topic - next topic

simmering123

Dear community,

unfortunately I have some problems with my LCD Keypad Shield. I am using an Arduino Mega 2560 and the following Shield: kwmobile LCD Display Module, https://www.amazon.com/kwmobile-display-module-keys-Arduino/dp/B01EYW5R5M   I

The problem is that the backlight is on but it is not able to display anything.

I tried it with the following code (and many other codes) but it doesn't work.
Code: [Select]

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
}

 Could it be the wrong pins? I have just bought the shield. The LCD is just blue.

Thanks for your help!

INTP

You need to find the code from the shield maker to tell you which pins to use. Or look closely at the traces on the shield. Your code shown also has nothing to do with buttons, so you copied a wrong code.

simmering123

Ok, the pins are correct now, I also copied a button code
Code: [Select]
//Sample using LiquidCrystal library
#include <LiquidCrystal.h>

/*******************************************************

This program will test the LCD panel and the buttons
Mark Bramwell, July 2010

********************************************************/

// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// define some values used by the panel and buttons
int lcd_key     = 0;
int adc_key_in  = 0;
#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5

// read the buttons
int read_LCD_buttons()
{
 adc_key_in = analogRead(0);      // read the value from the sensor
 // my buttons when read are centered at these valies: 0, 144, 329, 504, 741
 // we add approx 50 to those values and check to see if we are close
 if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
 // For V1.1 us this threshold
 if (adc_key_in < 50)   return btnRIGHT; 
 if (adc_key_in < 250)  return btnUP;
 if (adc_key_in < 450)  return btnDOWN;
 if (adc_key_in < 650)  return btnLEFT;
 if (adc_key_in < 850)  return btnSELECT; 

 // For V1.0 comment the other threshold and use the one below:
/*
 if (adc_key_in < 50)   return btnRIGHT; 
 if (adc_key_in < 195)  return btnUP;
 if (adc_key_in < 380)  return btnDOWN;
 if (adc_key_in < 555)  return btnLEFT;
 if (adc_key_in < 790)  return btnSELECT;   
*/


 return btnNONE;  // when all others fail, return this...
}

void setup()
{
 lcd.begin(16, 2);              // start the library
 lcd.setCursor(0,0);
 lcd.print("Push the buttons"); // print a simple message
}
 
void loop()
{
 lcd.setCursor(9,1);            // move cursor to second line "1" and 9 spaces over
 lcd.print(millis()/1000);      // display seconds elapsed since power-up


 lcd.setCursor(0,1);            // move to the begining of the second line
 lcd_key = read_LCD_buttons();  // read the buttons

 switch (lcd_key)               // depending on which button was pushed, we perform an action
 {
   case btnRIGHT:
     {
     lcd.print("RIGHT ");
     break;
     }
   case btnLEFT:
     {
     lcd.print("LEFT   ");
     break;
     }
   case btnUP:
     {
     lcd.print("UP    ");
     break;
     }
   case btnDOWN:
     {
     lcd.print("DOWN  ");
     break;
     }
   case btnSELECT:
     {
     lcd.print("SELECT");
     break;
     }
     case btnNONE:
     {
     lcd.print("NONE  ");
     break;
     }
 }

}


Is this code ok? I saw that in some videos that after the shield was supplied with power it already displayed something (16x2 lcd squares), mine does not. It is just blue. Is that normal?

Or has it something to do with the backlight control?

cattledog

Have you adjusted the contrast pot? You should be able to see "squares" on one row of the device with no code running, but just power applied.

simmering123

Thanks for the tips, strangely, it does not display any squares, no matter how much I spin the pot. It is just blue(see attachment).

cattledog

Sometimes the multi turn pots can be deceiving. Have you found both ends of the range? If you can not get squares to show with the pot setting, then something maybe wrong with the pot or the display. You may be able to trouble shoot the pot by measuring the resisitance with the shield unpowered at the pot connecton on the underside of the shield.

If the pot is defective, you can also try to find a contrast setting which works by jumpering a resistor (in the range 200 ohm through 2k ohm) from pin 3 of the lcd to ground and bypassing the pot.

cattledog

One additional item to check is if you indeed have ground on pin 1 and 5v on pin 2 of the lcd.

The backlight is obviously working, but I'm not sure if its power is actually tied to the Vcc and Gnd for the lcd display.


bperrybap

The link to the product in the first post does not work.

The pins used to control the LCD were not change between post #0 and post #2.
The seller should provide you the information as to how the pins are wired up to the LCD.
You need that information in order to tell the LiquidCrystal library how to control the LCD.
If the seller refuses to give it to you, you will have to figure it out.
If you use and ohm meter it should only take a couple of minutes to track down which Arduino pin is wired up to which LCD pin.

Once you know that you can then fill in the appropriate numbers into the LiquidCrystal constructor.

--- bill

bodmer

You probably have a display with a 10 turn pot.  Power the board, turn the pot screw 10 full revolutions clockwise, (you may hear a "clicking" when it gets to the end of travel) Then try turning the pot 10 turns anticlockwise.  You should get either a set of white blocks or the correct text.

simmering123

Ok, thanks for all your replies. I contacted the seller and he said that the shield is defective and he will send me a replacement for free. But I will try your solutions as well. ;)

dmilton2004

Thanks to everyone with this topic. I just bought 3 of these from Wish.com and I thought I had bad units. I looked at the link for the item and they look identical to the ones I purchased. I tried the standard Arduino LCD library the same example sketch with the pins modified to what the original poster had and got nothing. I read all your posts and the one that really helped was the fact it is a 10 turn POT.

That was the kicker! It took more than 10 turns though. I read the POT with my meter and it looks like a 10K ohm POT. It was in the 7k-8k range. Cannot see how that every left quality control working! I turned them way down until I saw the blocks and tuned it until the letters are now white with a blue background.

Almost had them start a refund but viola! It is now working great!

Thanks again! 

nliveris

Hello, I would like to know if there is any documentation for this shield and where to find it. Thank you in advance.

Go Up