Pages: [1]   Go Down
Author Topic: LCD4Bit lib  (Read 1212 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
God Member
*****
Karma: 2
Posts: 854
Arduino rocks!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was reading ladyada's LCD tutorial and she suggests changing the pins as needed in the LCD4Bit.cpp file.  

Can't I just change the variables in my sketch?  I prefer not to change libraries because it can lead to nightmarish bugs if I move the code onto a new system or reinstall.
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6250
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You do need to have the pins in the lcd4bit library source match the physical wiring, the library is compiled before your sketch so setting the variables in the sketch won't change the pin assignments.

Although its possible to modify the library so that the pins can be assigned when the library is initialized, the compiler will produce less efficient code if it doesn't know the pin numbers at compile time, so this is not something I would recommend.

You could add a #define in the library header file so that your sketch can verify that the files in the library directory has had your personal attention.

Putting something like the following in the lcd4bit.h header file:
   #define MYSOURCE

And the following in a sketch that uses the library:
#ifndef MYSOURCE
   SOURCE CODE NOT CUSTOMIZED  // Generate compiler error if MYSOURCE is not defined
#endif

So if you accidently update the lcd lib source files the compiler will complain, reminding you to change the pin assignments to the ones you use.
Logged

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

I found a couple strange bugs in the LCD4Bit library that was posted on the playground... It was a while ago though, but I think one of the bits got stuck somewhere along the line... though that might have been the version for using an I/O expander as well. Hmm...
Logged

0
Offline Offline
God Member
*****
Karma: 2
Posts: 854
Arduino rocks!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You could add a #define in the library header file so that your sketch can verify that the files in the library directory has had your personal attention.

That's brilliant.  I love learning new techniques like that.

I guess I can also rename the .cpp and .h files so that I don't accidently use them in a new sketch thinking it should match the pins in the docs because I forgot I changed it.

Anyone have comments on MysteriousAges note about bugs in the library?
Logged

New England
Offline Offline
Jr. Member
**
Karma: 0
Posts: 95
Arduino newbie
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I found a more configurable LCD library a little while ago.  Main page is here: http://www.slashdev.ca/arduino-lcd-library

The pins are configurable via software, and it uses the R/S (or is it RW?) line instead of hard-coded delays, so it should be more efficient and faster.  I've only just started playing with it and I think I've got some wiring issues at the moment, but it's got promise.  
Logged

0
Offline Offline
God Member
*****
Karma: 2
Posts: 854
Arduino rocks!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I found a more configurable LCD library a little while ago.  Main page is here: http://www.slashdev.ca/arduino-lcd-library

The pins are configurable via software, and it uses the R/S (or is it RW?) line instead of hard-coded delays, so it should be more efficient and faster.  I've only just started playing with it and I think I've got some wiring issues at the moment, but it's got promise.  

Right now, I'm trying to solder something together to play with an LCD, but I'm having trouble deciding how to do it.  Ladyada's way is great but I forgot to order spare protoboard PCB's smiley.

I have plenty of perf board but it doesn't line up with the pins.   So I'm thinking of something that will connect to the pins 0-7 header and use 2-7 as my 6 lines, then have wires coming off it to ground and vcc.  It sounds pretty sloppy though and I haven't decided how to connect the LCD itself.  I like the female socket idea but I was envisioning a small piece of perfboard, so the whole thing might not be mechanically strong enough or put too much pressure on single ardunio socket it's connected to.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello guys. Im having troubbles using all LCD libraries i've found over there (Massimo's, Tomek's, playground's, the one from the previous posts, and some others I dont remember now)

The fact is that I make the wiring as the library needs to, but I cannot see anything when loading the examples into the arduino. I dont know why. I remember one day managed to write only at the first line of the LCD, and when I tried to start up the LCD with two lines, I got no letters readeable.

Could my problem be that, the examples I run, configured the LCD with 2.lines and I dont have enough power to write on them? I have LCD's Vcc input connected to 5v. from arduino.

Thanks in advance mates.
Logged

Pages: [1]   Go Up
Jump to: