Pages: [1]   Go Down
Author Topic: initializing LCD library within setup() ?  (Read 295 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Instead of this:

Code:
// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
// RS, E, D4, D5, D6, D7
LiquidCrystal lcd(53, 51, 41, 37, 39, 35);

setup() {
 // stuff...
 lcd.begin(24, 2);
 lcd.print("  Hello ");
}

loop() {
 // stuff..
 lcd.print (" Looping ");
}

How can I "prolong" and re-use the initializing of LCD hardware.  I'd like to do something like this:
Code:
// include the library code:
#include <LiquidCrystal.h>

setup() {
 // stuff...

 digitalWrite (LCDpower, HIGH);
 delay(2000);
 LiquidCrystal lcd(53, 51, 41, 37, 39, 35);  

 lcd.begin(24, 2);
 lcd.print("  Hello ");
}

loop() {
 // stuff..
 lcd.print (millis());
}

When I try, I get scope issues with lcd.print in the loop().

Is there a way to declare the lcd commands in loop() as "extern" or something?


The reason I'm doing this is sometimes I need to recycle power on the LCD because it gets garbled.  I've tried adding robustness to its power, cutting down noise,  etc and will continue on that front but in the meantime I need to hard boot the LCD without resetting the Arduino.

Thanks!
« Last Edit: April 27, 2010, 11:12:25 am by scottmcphee » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Please don't crosspost.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1272390339
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was hunting for a home for this topic.  

Like so many things, microcontroller based products have some pretty tightly integrated hardware and software dependencies.

This is a perfect example.

I found the most responsive place is in the software development forum, it's byline includes the words "libraries"... and I think this is truly a bad library design issue.  

Technically this is not an interfacing issue, the library actually drives the module fine.

It's getting good traction over there...  consider the conversation shifted.
« Last Edit: April 27, 2010, 04:33:55 pm by scottmcphee » Logged

Pages: [1]   Go Up
Jump to: