Go Down

Topic: initializing LCD library within setup() ? (Read 440 times) previous topic - next topic

scottmcphee

Apr 27, 2010, 05:51 pm Last Edit: Apr 27, 2010, 06:12 pm by scottmcphee Reason: 1
Instead of this:

Code: [Select]

// 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: [Select]

// 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!

Coding Badly


Please don't crosspost.

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

scottmcphee

#2
Apr 27, 2010, 11:30 pm Last Edit: Apr 27, 2010, 11:33 pm by scottmcphee Reason: 1
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.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy