Using the LCM1602, What is the REAL Code for the Adruino Leonardo?

All I want is a simple pre written code that works so I can do more than just sit here and play at data entry puncher of code that may or may not and usually doesn’t work!

All I want is a simple pre written code that works so I can do more than just sit here and play at data entry puncher of code that may or may not and usually doesn't work!

Yeah, there's a name for it . It's called programming. If you are looking for a program, you need to first identify the lcd that you are using.correctly. Your title says "LCM1602" but clearly "(from the photo), there is more to it than that. (everyone else knows what I mean). Please CORRECTLY identify the lcd you are using and post a link to where you got it. Also post your code if you have any.

All I want is a simple pre written code that works so I can do more than just sit here and play at data entry puncher of code that may or may not and usually doesn't work!

Please post the code you are trying to use along with a link to where you purchased your lcd. You have given us no specific information on your lcd and there are thousands of different types. The information you gave us is incomplete.

All I want is a simple pre written code that works so I can do more than just sit here and play at data entry puncher of code that may or may not and usually doesn't work!

I think there's a pre-written program that will 'play at data entry' for you, the I2C LCD Guesser.

It looks like you are using I2C adapters with your displays and there is no real standard for those.

You have to determine the 'address' of the adapter which depends partially upon the particular chip on the adapter and partially upon the status of the jumpers which I think are right below the blue potentiometer.

You also have to determine the wiring between the chip on the adapter and the pins that go to the display.

If I am not mistaken the I2C LCD Guesser will do both of these for you. The author will probably chime in here shortly to give you the correct answers if I am mistaken.

Don

I2CLCDGUESSER --> [SOLVED] MJKDZ brand I2C Controller working with 1602 LCD - Displays - Arduino Forum

I think there's a pre-written program that will 'play at data entry' for you, the I2C LCD Guesser.

Of course we know that would work but that's not the point. If the OP will just provide the link of the vendor where he got it
that may (or may not) speed things up, depending on whether or not we recognize it.

My 2cents, use the I2C scanner to get the address of the adapter, then use the Lcd guesser with that address
Both have worked for me.
Cheers
Peter

FYI, if you use the Guesser, it might be necessary to change the Serial Monitor line ending parameter to NEWLINE.

Actually, if I use guesser I would probably have to use the line "Buy me a new LCD"
To answer your query.....they are your standard, run of the mill, everyone has one, Ebay model that is more than likely a clone of another Ebay model that all the other people have. So still my question is ....Where is the proper code? I've tried just about every one I could find with all their special twists because this model or that model needs this line or that line. Hay, this isn't rocket science here, we are only talking 4 wires!

Southview:
Actually, if I use guesser I would probably have to use the line "Buy me a new LCD"

Huh? What are you talking about?
You seem to have a LCD with an i2c backpack.
That is what the guesser helps you with.

So still my question is ....Where is the proper code? I've tried just about every one I could find with all their special twists because this model or that model needs this line or that line. Hay, this isn't rocket science here, we are only talking 4 wires!

And Just you like you said, It isn't rocket science.
People answered your question.
Go get the guesser sketch. Follow the instructions in it.

--- bill

You obviouly don't know about the Costructor statement that TELLS you how to connect it or how to use I2C.
Google that and then you will see why you need the Guesser.
FYI, it's ARDUINO, not "Adruino".

You obviouly don't know about the Costructor statement that TELLS you how to connect it or how to use I2C.

I was under the impression that the constructor tells the library how the designer of the pc board chose to connect the IC pins to the interface pins. It also tells the library what the I2C address for this particular setup is.

FYI it's obviously not 'obviouly' and it's constructor not 'costructor'.

Don

To answer your query.....they are your standard, run of the mill, everyone has one, Ebay model that is more than likely a clone of another Ebay model that all the other people have.

It's not quite as simple as that. There is no such thing as a standard, run of the mill I2C adapter. Yes many of them look the same, but they are not all wired the same.

Also, some that are indeed wired identically happen to use different ICs resulting in different I2C addresses.

Don

Your funny Don. I can't see the text on my cell phone. You know I usually don't make SPLELLING ERORS...

floresta:
It’s not quite as simple as that. There is no such thing as a standard, run of the mill I2C adapter. Yes many of them look the same, but they are not all wired the same.

Well, they often look similar, but have visibly different component placements which may or may not correspond to different wiring, possibly only the polarity of the backlight control, if that.

floresta:
Also, some that are indeed wired identically happen to use different ICs resulting in different I2C addresses.

Very few I think using the alternate IC; most are either 0x20 or 0x27 which are the two range ends of the same chip and either - or any in between - can be set if they have the address jumpers, sometimes as a set of six unmarked "thru"s.

Southview:
Actually, if I use guesser I would probably have to use the line “Buy me a new LCD”

No. Whilst bperrybap’s “guesser” carries the standard legal disclaimer, “all care but no responsibility”, no-one has posted a genuine report of a “wrong” guess causing damage, nor is it really likely.

Southview:
They are your standard, run of the mill, everyone has one, Ebay model that is more than likely a clone of another Ebay model that all the other people have.

Of no less than seven “run of the mill” designs. I am making it a point to collect at least one of each - of the cheap ones at least

Southview:
So still my question is …Where is the proper code? I’ve tried just about every one I could find with all their special twists because this model or that model needs this line or that line.

No point running around looking for various codes. The proper code is the “guesser”. If it works, it tells you the correct “constructor”; on the LCD itself, which you then write into any other code you wish to run using the fmalpartida library.

If the “guesser” cannot locate the device address, you have the SDA and SCL connections wrong and these are different on the Leonardo to other Arduinox. Once it locates the address, you need to have the Serial Monitor working correctly so that each time you type an “Enter”, it steps to the next trial constructor and shows it on the Serial Monitor. If it is not doing that, then your serial port configuration is wrong. If it is showing a different constructor each time you Enter, and only when you Enter, then one of tehm will be the correct one which displays on the LCD (but only if the LCD is actually connected to the backpack, with pin 1 to pin 1 - if it is backwards, the LCD will be on all the time).

Southview:
Hay, this isn’t rocket science here, we are only talking 4 wires!

Hay is what sheep and horses eat.

The reason I have a disclaimer in the guesser sketch is that there actually is a potential for damage.
The PCF8574 doesn't source any current on its output pins but it does sink current.
Some of the backpack designs hook up the R/W line to a PCF8574 pin.
If the wrong PCF8574 pins are used to talk to the LCD pins,
then there is a possibility that the LCD ended up read mode and the E was stobed high.
If that happens, then if the LCD is driving a data line high and that is hooked
to a PCF874 pin that is is trying to drive it low, there is a bus collision.
These chips and the LCD are pretty tough, but with a bus/pin collision
there is the potential for damage as the pins are potentially fighting
each other.

That said, I have looked at many PCF8574 based backpacks (12+), and so far
I've only seen 4 different ways the PCF8574 is hooked up to the hd44780 pins.
Of the 4, one is fm's ElectroFun LCD Extra i/o board that very few people have
and 2 of the remaining 3 are the same other than the backlight polarity.
So in reality there are only 3 ways people are talking to LCD and of those
2 of them are the ones that the ebay vendors are using and
by far 1 of those is the most popular.

The ordering of guesses takes into consideration these known wirings to avoid
any potential damage and why you want to stop as soon as you see the correct one,
but it is possible that there are still some other boards
out there that wire up the pins differently and might have a bus collision issue
when the guesser is run.

As far as addressing goes, it is more than just 0x20 - 0x27.
It depends on the manufacturer and the chip package used.
Ive seen chips in the 0x30 and 0x40 range as well.
In fact 0x38 is also a common address.

--- bill

Thanks Bill, that made things more coherent. It isn't less frustrating but explains why it is so!

ou obviouly don't know about the Costructor statement that TELLS you how to connect it or how to use I2C.
Google that and then you will see why you need the Guesser.

My comment above was incorrect because I forgot you were using I2C, where the address is the critical parameter , whereas with parallel lcds, the constructor does actually provide info the user needs to connect it.

... whereas with parallel lcds, the constructor does actually provide info the user needs to connect it.

No it doesn't. It performs a similar function as it does for the I2C setup. In this case the constructor tells the library how the pins on the LCD module relate to the pins on the Arduino.

The user must make sure that the actual hookup matches the constructor (or vice versa) but the purpose of the constructor is to give that information to the library.

Don

No it doesn't. It performs a similar function as it does for the I2C setup. In this case the constructor tells the library how the pins on the LCD module relate to the pins on the Arduino.

The user must make sure that the actual hookup matches the constructor (or vice versa) but the purpose of the constructor is to give that information to the library.

(This is saying the same thing I just said. The constructor provide info the user needs despite the fact that it is there for
the library, the user still needs it. Any way you cut the cake , you are agreeing with me because you are saying the user needs to know that while at the same time saying that I am wrong for saying that. You should quit while your ahead.

whereas with parallel lcds, the constructor does actually provide info the user needs to connect it.

but the purpose of the constructor is to give that information to the library.

Do you see the word "purpose" in my statement ?
Either it provides information that the user needs or it doesn't . If you say the user must pay attention to that information then you are simply confirming what I said which is that the user needs that information, otherwise why would you tell him to pay attention to it ?

Guys there is a lot of side comments and what appears to be arguing around yourselves
rather than helping Southview get his board going.
Keep in mind that based on his number of posts,
he could be fairly new to Arduino and h/w & s/w type issues.
I'm willing to cut him some slack given his apparent newness.

Southview, if you download the guesser sketch, you will read in the comments of the sketch
what you need to do get it up and running, including where to download the proper LCD library.
If after reading the guesser instructions or things are still not working, report back
and we'll try to help you.

--- bill

Guys there is a lot of side comments and what appears to be arguing around yourselves
rather than helping Southview get his board going.

I’m sorry Bill but it does the beginners no good to let erroneous or misleading information get perpetuated.

If you look at my responses to the OP you will see that they were correct and to the point. I didn’t introduce any extraneous or misleading information, all I did was correct the information that was added by raschemmel.

I did not respond to the last post by raschemmel because there is no way to logically refute such jibberish.

Don