Go Down

Topic: LCD Shield not behaving (Read 23075 times) previous topic - next topic


First. By looking at the code, the push buttons use the analog pins, not the digital pins.

my buttons when read are centered at these valies: 0, 144, 329, 504, 741

Those values are the analog value. A number between 0 = 0 V to 1023 = 5 V

The way the buttons is connected and the need a read which key is press based on the value being measured by the analog adc.

In my opinion anyway...


I've got lots of questions about this but let's start with these comments:
// my buttons when read are centered at these valies: 0, 144, 329, 504, 741 Where do these values come from?
// we add approx 50 to those values and check to see if we are close  Why do we add approx 50 to each value?

It's a voltage divider. So the total resistance is 2K + 330 + 620 + 1K + 3.3K which is 7250 ohms.

So if the top switch is pressed we get a voltage of 0 since we are grounding the ADC through the 2K resistor.

The next switch down will give (330 / (2000 + 330)) * 1024 = 145.

The next switch will give ((330 + 620) / (2000 + 330 + 620)) * 1024 = 329.

And so on.

I presume we add 50 to give a "fudge factor" so that the voltage doesn't have to be spot on, but within the range of this switch, compared to the next one in sequence.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics


Mar 13, 2012, 05:18 am Last Edit: Mar 13, 2012, 05:26 am by bperrybap Reason: 1

Also, where did you find the info that pins Arduino (RS, E, D4, D5, D6, D7) interface with LCD pins (8, 9, 4, 5, 6, 7)?

I found this schematic but I can't see that it provides this info anywhere.

Look closely at the schematic.
See the red/brown "D4", "D5", "D6", "D7" going to the 1602 DB4 to DB7?
The "D4" is Arduino digital pin 4, "D5" is Arduino digital pin 5, etc...
Also note D8 going to RS and D9 going to E.

As a bonus look over on the right at the transistor,
Arduino digital pin 10 controls the transistor so you can control the backlight with pin 10.
(Pin 10 supports PWM so you should be able to use analogWrite() and dim the display backlight)

You can also reference their document which has this information in it as well:
See the user guide then page through until you get to the LCD&Keypad shield.

--- bill


The switches on the shield are all connected to +5V and the analog in pin with a resistor in between. The resistors are different sizes, so the voltage that the analog pin sees depends on which switch is pressed.

The analogRead() function reports that voltage as an integer value in the range 0 to 1023 corresponding to 0 to the reference voltage (usually +5V).

So, the code is showing the usual value that would be read at each pin, if the reference voltage is exactly 5.000V and the resistor is exactly the nominal value and the switch is ultraclean (provides no resistance). Since none of these assumptions is true, the value actual reported will only be close to the nominal value shown.

Therefore a fudge factor is added in.
The art of getting good answers lies in asking good questions.


Mar 13, 2012, 12:44 pm Last Edit: Mar 13, 2012, 12:48 pm by floresta Reason: 1

Also, where did you find the info that pins Arduino (RS, E, D4, D5, D6, D7) interface with LCD pins (8, 9, 4, 5, 6, 7)?

I found this schematic but I can't see that it provides this info anywhere.

You've got the first part backwards - Arduino pins (8, 9, 4, 5, 6, 7) interface with LCD pins (RS, E, D4, D5, D6, D7).

Sorry I'm late, Bill already answered the second part, but here it is again.  On the schematic look at the IC in the upper right section.  If you follow the wire from the RS pin (LCD pin 4) you will see the term 'D8' which stands for Arduino digital pin 8.  The other pins have similar information.



Anybody else notice a backlight control problem in the DFRobot schematic?

D10 is hooked up straight to the 9013 base with no current limiting resistor.

When D10 is an input, the pullup will turn on backlight.
When D10 is an output and low the base goes low and the transistor turns off.
But when D10 is an output and high won't it
"short" through the transistor to the emitter?

Seems like the circuit is missing a diode to ensure that D10 only pulls the base low
and lets the resistor pull the base high.

Without the diode it seems like D10 really needs to either be an output with the pin low to turn
off the display or an input to turn on the display which precludes the use of PWM.

I have a shield that uses a similar circuit. Mine also has a switch to disconnect the ground to the
transistor emitter so you can permanently disable the backlight.

I just measured the current from D10 when D10 is high and it is 95ma!!!
I guess it is lucky that the pin output was not fried.

While the AVR doesn't get "hot", it does get warm when D10 is high
for a few minutes.

Anyway, I'm in the process of modding my shield with a diode.
It looks like an easy mod on the shield I have as the trace to D10 is on back of the shield
for a little bit up by the header before going through to the other side to the transistor which is under the LCD.
Just cut the trace and solder a diode back to the trace.

I'll post a few before/after photos after I get the mod done.

--- bill


Mar 13, 2012, 10:16 pm Last Edit: Mar 13, 2012, 10:20 pm by floresta Reason: 1
But it's on the Internet, it must be OK.

If they had taken the time to draw a proper schematic diagram they might have spotted that obvious error.  It's too bad that people think that these monstrosities (produced I think by Eagle) are true schematics. 



Here is a thread I started about the backlight control circuit issue:
with some photos of the emartee shield I modified.

--- bill


The shop I bought the Uno and the shield at said they plug together. The pins all line up only one way.

See attached photos. Thats how the screen looks no matter what I do. The only time it changes is when I reset it and then it blinks off then back on.
I've got exactly the same issue.
mine if from OSEEP. Grrrr.


Hi there
I tested the codes from the below address: for my LCD Shield
both <LiquidCrystal.h> and  <LCD4Bit_mod.h> libraries:
but the lcd shield do nothing with any codes, The shield contrast popotentiometer dosn't work too ... I mean it has no effect to the back-light of the LCD!
what should I do to test my shield and displaying something instead white boxes.


Does any body have a working code for DFROBOT 1602 arduino shield?
all the codes that I tried them before, NOT working ...  all the time with any program, the LCD displaying the white boxes! ahhh


my 1602 lcd keypad shield is labeled as "D1 ROBOT". it looks exactly the same to yours.

here's my constructor.

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

to turn off the backlight

to dim
analogWrite(10,50); //max brightness is 255

Go Up