Arduino and I2c LCD

Home Model Engine Machinist Forum

Help Support Home Model Engine Machinist Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
The end goal is add a keypad to Chuck F's RT sketch. Right now, I'm trying to learn how to use the I2c serial module with a 1602 LCD. I bought 2 of the modules, and a LCD. Got the modules, but the extra LCD hasn't come in yet. The LCD I'm using came in the Adafruit accessory kit. It has only one set of output pins, and I had already soldered header pins to it so I am plugging the LCD and the I2c module into a breadboard. I cannot get either I2C module to display anything but blocks with all pixels lit using the Sainsmart library and the I2c LCD example. I finally got a serial address scanner to work to verify the modules addresses, but no character display.
I'll go back to that tutorial you linked and play with changing the address.

I do have a 20x4 LCD with 2 sets of output pins. One set has a header soldered in. Can I solder one of the serial modules to the other without causing problems? I can't mount that LCD on the breadboard I have with the header on it, and mount the serial module too.

Chuck

Edit: Yes, the example sketch has the Wire.h in it.

Ok now if you are using the example code all it does is turn your screen on and off no text.
you are using 2 boards on is the master and the other one a slave
 
I do have a 20x4 LCD with 2 sets of output pins. One set has a header soldered in. Can I solder one of the serial modules to the other without causing problems? I can't mount that LCD on the breadboard I have with the header on it, and mount the serial module too.

Chuck

I don't have a display with two sets of output pins, but if that is what the other set of pins is, you shouldn't have a problem as long as you only have one set connected at a time.

You are able to compile the program without errors, correct?

I hooked mine up this morning and had nothing but trouble until I went back and installed the LiquidCrystal_I2C library through SKETCH>IMPORT LIBRARY>ADD LIBRARY command.

Once I did that, I ran the Hello World sketch that was in DOCUMENTS>ARDUINO>LIBRARIES>LIQUIDCRYSTAL_I2C2004V1>EXAMPLES>HELLOWORLD.
It compiled and ran first time with no errors.

BTW, mine was at the default address of 0x27 and I didn't need to change the baud rate. I don't remember where I got mine, but I know it wasn't SainSmart.

Steve Fox
 
I don't have a display with two sets of output pins, but if that is what the other set of pins is, you shouldn't have a problem as long as you only have one set connected at a time.

You are able to compile the program without errors, correct?

I hooked mine up this morning and had nothing but trouble until I went back and installed the LiquidCrystal_I2C library through SKETCH>IMPORT LIBRARY>ADD LIBRARY command.

Once I did that, I ran the Hello World sketch that was in DOCUMENTS>ARDUINO>LIBRARIES>LIQUIDCRYSTAL_I2C2004V1>EXAMPLES>HELLOWORLD.
It compiled and ran first time with no errors.

BTW, mine was at the default address of 0x27 and I didn't need to change the baud rate. I don't remember where I got mine, but I know it wasn't SainSmart.

Steve Fox

After I got the I2C scanner working, I found the address of my modules was 0x27. As long as I make sure that is in the sketch, it works. I have had some confusion over libraries. I think I've got that fixed now. The tutorial by Dr Schlaf works now that I have his I2C library correctly loaded.

Chuck
 
More success today. With the help of Luc, Steve, TB, and others, and several videos and tutorials, I have the I2C module driving my LCD, and a 4x4 keypad connected correctly. Now to merge this code with Chuck F's version and see if I can make more progress. I still have Chuck F's version as written, loaded on one setup, and my developing version on another.
I will gladly share what I have working, if anyone wants it. I will end this thread an start another on my mod of Chuck F's code.

Chuck
 
More success today. With the help of Luc, Steve, TB, and others, and several videos and tutorials, I have the I2C module driving my LCD, and a 4x4 keypad connected correctly. Now to merge this code with Chuck F's version and see if I can make more progress. I still have Chuck F's version as written, loaded on one setup, and my developing version on another.
I will gladly share what I have working, if anyone wants it. I will end this thread an start another on my mod of Chuck F's code.

Chuck

Chuck, great you got it up and running, please don't think I'm pushing my own barrow but look at this thread
http://www.homemodelenginemachinist.com/showthread.php?p=261884#post261884
Post #20 has all the libraries and working code. The main improvement over Chuck Fellowes sketch is that we are using an Interrupt driven stepper driver which is much more efficient. I have a list of enhancements to add to this code. If you adopt the component values of the Freetronics keyboard and you can get outout to your screen from my code, you will be in business.
 
My I2c Serial setup still doesn't work with the 'Hello World' example sketch.
I have tried ox20 and 0x27 addresses, no go. LCD flashes and lights the top row, contrast works, but no readable characters. Digits on the LCD are just white squares.
If I add the declare statements above, where do I put them in the sketch?
Pics of setup.
Chuck
I had the same I2C backpacks and the same results. It was the Libary. Carl
 
You got it Carl. I watched a video Luc posted. Spent a while trying to find the code and Library they used, and with their Library it worked.

Chuck
 
You got it Carl. I watched a video Luc posted. Spent a while trying to find the code and Library they used, and with their Library it worked.

Chuck

Are you going to post that library to the downloads section, or post a link to it Chuck?
 
Here's a link to the "Let's Make It" episode 5, that discussed the I2C serial Module. Scroll down the page for their code and a link to download the library.
I also used a serial bus scanner to find the address of the serial modules before the above cod worked. I had to modify the scanner sketch to output in hex addresses to understand what my modules address was.
I attached my modified version of the scanner.

Chuck

Couldn't attach the sketch. .ino file extentions as attachments are not allowed. I'll play with some other formats and see if I can attach it.
 
Last edited:
Terry, I have since gotten the scanner and the I2C module to work. The sketches had the wrong address in them. The scanner that I got to work identified the hex address of the I2C module. After I modified the sketch to that address, it worked as advertised.

Chuck
 
Back
Top