[SOLVED] - Switching LCD On/Off

A.R.Ty:

Have you considered how much current the backlight requires and compared this with the 20 mA recommendation for the I/O port?

you mean with math, calculation and formulas ?
No - it works and thats the only thing that counts for me :smiley:

A.R.Ty,
your comments here are offering bad advice and are not helpful.
hobbit666 clearly specified the display that he has (12864ZW) which is a st7920 128x64 glcd.
In your reponses you are giving advice based on showing examples for a totally different
type of display - a character based hd44780 based display which is
nothing like the display that hobbit has.

Don was subtly pointing out that what you have recommended
could possible damage the AVR chip.

If you were to read the datasheets for a larger display like the 128x64 glcds
you would find out that they need considerably more current than what
the AVR can supply from a pin.
I have measure many glcd backlight lights that use 200ma or more with a few
that use as much 400ma.
Since I actually had a 12864ZW laying around, I took the time to measure the backlight
current for that exact display.

It was 60ma.
While it is much lower than the typical ks0108 type displays that I have,
it is still much higher than what an AVR pin can drive.

So there you have it. No math, calculations, or formulas,
just real world measurements and reality.
You can't drive the 12864ZW anode pin directly with an AVR pin.

hobbit,
I'd recommend using a transistor to drive the backlight.
Here is note from what I recommend in my openGLCD project for driving
the backlight on glcds. For these circuits you will connect the Arduino pin
to the BL input.

 * Example Backlight Circuits:
 *
 * N-CH Mosfet version: (More costly but less power draw and lower part count)
 * ---------------------------------------------------------------------------
 *
 *                (value depends on GLCD, 100ohm is usually safe)
 * (LCD BL anode)---[ resistor ]---(VCC)
 *
 * (LCD BL cathode)---------------+
 *                                |
 *                                D
 *                                |
 * (BL input)----------------G-|-< (2N7000 FET)
 *                                |
 *                                S
 *                                |
 *                              (GND)
 *
 * NOTE: Gate resistor not needed as the mosfet is voltage fed and only really
 *       pulls current while switching.
 *
 * Here are two example backlight circuits that can be used:
 *
 *
 * NPN Transistor version: (Cheaper but more power draw and higher part count)
 * ---------------------------------------------------------------------------
 *
 *                (value depends on GLCD, 100ohm is usually safe)
 * (LCD BL anode)---[ resistor ]---(VCC)
 *
 * (LCD BL cathode)---------------+
 *                                |
 *                                C
 *                                |
 * (BL input)--[ Resistor ]---B-|> (NPN) 2N2222A/2N3904 etc...
 *                  1k            |
 *                                E
 *                                |
 *                              (GND)
 *
 * NOTE: The Base resistor is needed because the NPN is current fed.  For lower
 *       power draw, try a 10k resistor.
 *
 * In either case, when the BL input is HIGH the LCD backlight will turn on.

--- bill