Pages: [1]   Go Down
Author Topic: [SOLVED] - Switching LCD On/Off  (Read 951 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a cheap 128x64 graphic lcd (12864ZW) and got it all working etc.

I'm trying to do a small project that when a push a button (may change to proximity sensor) the gLCD displays some messages/graphics etc. then clears until activated again.  As this will be a standalone project and want to save battery (going to use a 9V battery) can I just plug the +5V of the LCD into a pin on the Arduino and when the switch is pressed make that pin on/live/enabled to supply the +V to the screen?  I'm just trying to get the thing working on breadboard at the moment but need some help so i can get the components ready.

Or will I need to do this with a relay of some sort?
« Last Edit: December 04, 2013, 11:05:05 am by hobbit666 » Logged

DE
Offline Offline
God Member
*****
Karma: 21
Posts: 710
| Germany | NRW |
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hoi,

connect the Power-pin of the LCD backlight with a cable and a resistor to a port of your ARDUINO.
Setting this port HIGH will switch the light on, LOW switches it off.
Logged

Dum spiro, spero - if you find my posting helpful, please click my Karma smiley
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Do you know A.R.T

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the quick reply,

220ohm do the trick?
Logged

DE
Offline Offline
God Member
*****
Karma: 21
Posts: 710
| Germany | NRW |
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yo, thats normal - but if your lcd has a resistor already on board you dont need it.
For sure try first with the resistor, if the light is to dark remove it and caryfully test it again

Here is a setup of one of mines:
Code:
#include <LiquidCrystal.h>
#include <Wire.h>
LiquidCrystal lcd(7, 8, A5, 10, 11, 12);
//                 Rs Rw En  D4 D5  D6  D7

#define   KONTRAST_PIN   14
#define   HG_PIN  A4
#define   KONTRAST      120

So if you give the contrast also an own pin you can control it by writing a value betweeen 0 and 128 (normally 256, but darker as dark didNt work at all  smiley-wink )
« Last Edit: November 27, 2013, 11:16:41 am by A.R.Ty » Logged

Dum spiro, spero - if you find my posting helpful, please click my Karma smiley
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Do you know A.R.T

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 4393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
connect the Power-pin of the LCD backlight with a cable and a resistor to a port of your ARDUINO.
Setting this port HIGH will switch the light on, LOW switches it off.

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

Don
Logged

DE
Offline Offline
God Member
*****
Karma: 21
Posts: 710
| Germany | NRW |
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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-grin
Logged

Dum spiro, spero - if you find my posting helpful, please click my Karma smiley
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Do you know A.R.T

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 4393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
No - it works and thats the only thing that counts for me
You can also drive 100 KPH in a 75 KPH speed zone . . . for a while.

Don
Logged

DE
Offline Offline
God Member
*****
Karma: 21
Posts: 710
| Germany | NRW |
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You can also drive 100 KPH in a 75 KPH speed zone . . . for a while.
Any more suggestion than this ?
Logged

Dum spiro, spero - if you find my posting helpful, please click my Karma smiley
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Do you know A.R.T

Offline Offline
Jr. Member
**
Karma: 2
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Almost all LCD displays have a data sheet on the 'net' if you Google it. That will give the current draw for the backlight Or you can use a voltmeter and measure the current. The Arduino suggests you stay within the 20ma range.

I measured several 4x20 LCDs for current draw and found they used a low of 53ma to a high of 275ma. I also have a 16x2 that uses 152ma. Trying to run any of those from the power of an Arduino pin would invoke the law of diminishing returns. As in one cooked Arduino chip.

A better/safer way would be to use one output pin to drive a transistor and have that act as a switch to turn the LCD backlight on and off. There are plenty of schematics for these simple switches around.

Mel

« Last Edit: November 27, 2013, 02:06:00 pm by wabbitguy » Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2738
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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-grin

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.
Code:
* 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




Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the info will try the transistor method cheers

Out of interest I'm new to arduino and relearning electronics.  How did you measure the power draw, just in case I need to test other devices

Cheers
Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2738
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you can google "how to measure current" and get lots of results.
Here is one of the videos that is pretty good:

With the glcd, there are two power measurements you can take.
- the power for logic circuity powered by VDD (pin2)
- the power for the backlight powered by pin BLA (pin 19)

The two are seperate. i.e. when you turn off the backlight the glcd circuitry is still powered
and running.

Since you are looking at making a battery powered device, you will want to take
note of the power of the overall device which includes the arduino.
One of the issues you may run into is that the typical Arduino will be a bit of power hog
when using an external power source even if the glcd backlight is off.
This is because the voltage regulator uses power to convert the input voltage
(9v in your case) down to 5v.

For a battery powered device you might want to find (or make) a solution
that doesn't use a voltage regulator, and then run it off 3 AA batteries
as it will give you much longer run time than a 9V battery.

--- bill
« Last Edit: November 27, 2013, 04:17:25 pm by bperrybap » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for all the help and info, looking at the transistor method guessing these will do:-
http://www.ebay.co.uk/itm/SparkyLabs-10-x-2N7000-N-channel-signal-mosfet-fairchild-60V-new-/181265746261?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item2a3447c955

This is for a project me and my daughter (9) are doing.  We are making a teddy that will have a LCD in it's belly that when a switch is pressed it displays some xmas graphics and messages from her and my other two kids.  She wanted to make her the teddy and when she saw my arduino and me playing with it her face lit up and so many ideas came out of her mouth.  Lego projects, doll house control etc etc.  So the battery on this project wouldn't need to last only a few days really but will look into maybe used 3xAA instead and no power regulator thingy smiley

Again Thanks for all the tips and the video link (after watching most of my high school electronics lessons came back lol)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thinking about the power, I've found possibly two solutions on Ebay (or work it out and build myself) but would these work and just plug direct onto my V+ and GND rails?

http://www.ebay.co.uk/itm/3x-Solar-Boost-DC-DC-3V-5V-Adjustable-Power-Supply-Module-F-DIY-mobile-power-/171011642579?pt=UK_AudioTVElectronics_HomeAudioHiFi_Amplifiers&hash=item27d11694d3
or
http://www.ebay.co.uk/itm/321186800480


Was looking at this but can't find the units for sale
http://www.instructables.com/id/Using-the-Pololu-5V-Boost-Regulator/

thx for the help
Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2738
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is a place to get inexpensive components:
http://www.taydaelectronics.com/
Logged

Pages: [1]   Go Up
Jump to: