what pins do I use with the arduino Micro and a serial LCD?

I am trying to figure out what pins to use on the arduino micro to print to a serial4 pin LCD. I have my my VCC to 5+ and my gnd to ground. the LCD lights up, but I am not getting a cursor or text. From what I have read it sounds like the SDA pin on the LCD goes to the TX pin on the micro, and that the SCL pin on the LCD goes to the RX pin on the micro, Is this correct? I just want to make sure that the connections are right, then I can focus on the code instead of wondering if the code is the issue, or the pin configuration is causing the problem.

Different arduino boards use different pins for SDC and SDA. I do not have a Micro, so I can not say for certain, but I read that pin 2 = SDA, and pin 3 = SDC.

Do you have any other arduino boards you could use for testing? I have a leonardo working with I2C, and can verify for that board.

I read the same thing, But I just want to be sure. I will dig a little deeper into the code. I dont have any other boards as of right now, I have a few others on order, but I have not gotten them yet.

The exact model of your LCD and Arduino would be helpful (links to the product page).
By SDA and SCL it sounds like an I2C LCD, therefore on an Arduino based on the Atmega328 chip the SDA pin is A4 and SCL is A5.
This also means you can't use the Serial class to send commands to the LCD, you will have to use a library which supports the LCD you have.
When we know what type of LCD it is we can recommend a library which will work for you.

Not all arduino boards use A4 and A5. My leonardo does not.

To be fair, he did mention that was for ATmega328 based boards. Your Leonardo is based on the ATmega32u4.

A quick look at the correct product page linked from
http://arduino.cc/en/Main/Products will tell which pins to use for which board.

Leonardo -

Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data using the ATmega32U4 hardware serial capability. Note that on the Leonardo, the Serial class refers to USB (CDC) communication; for TTL serial on pins 0 and 1, use the Serial1 class.

TWI: 2 (SDA) and 3 (SCL). Support TWI communication using the Wire library.

Micro -

Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data using the ATmega32U4 hardware serial capability. Note that on the Micro, the Serial class refers to USB (CDC) communication; for TTL serial on pins 0 and 1, use the Serial1 class.

TWI: 2 (SDA) and 3 (SCL). Support TWI communication using the Wire library.

(Both based on ATmega32u4)

image.jpg

OK, so we know that it is in fact a LCD module with a I2C "backpack".

The first thing you do with it, is to run the i2c_scanner sketch to immediately locate the address - also conveniently confirming that you have the correct connections (you can swap them as the sketch runs and watch the response on the serial monitor in the IDE).

Nest, you have to deal with the fact that there are at least two variants of the "backpack". These correspond to different descriptors in the LiquidCrystal_I2C library, so you may simply have to first try the two ones that I cite there with a simple test sketch - or the one in my previous posting.

Then you can move on to your more serious applications.

I ordered the LCD on Ebay, and there isn't a lot of a lot of info on it. they do include the LCD library which I have included in my sketch What little bit of info I have is "IIC LCD2004-character LCD" on the back of the LCD it has C2004A, and the i2C board has "T313S06" and "LCM1602 IC V1" printed on it. Here is a link to the product page http://www.ebay.com/itm/281141014288?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649 The main thing I am trying to figure out is where do I connect it to the board? I am used to setting a pinMode for the input and outputs, and I am trying to get a grasp on how to tell the board what pins to communicate with.

Well, for the "micro" as cited and diagrammed above, SDA goes to digital 2, SCL to digital 3 (as for the Leonardo).

Then use the test programs I suggested, and afterward, try the code from the seller. Perhaps more to the point, examine that code and try the descriptor that it gives, first in the "test" sketch. For the "LCM1602" backpack, the descriptor should be:

// set the LCD address to 0x20 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x20, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

but you must insert the address determined by the i2c_scanner sketch into the first parameter, 0x20.

I tried the I2C_scanner, and it loads, but I am getting nothing back from it. I tried to run the test code that The seller gives with the LCD, and I get 2 errors when it tries to compile. I dont understand why the sellers own code wont work. I am sure that the sellers code is good, but I am not understanding the issues. I will post the sellers test code, and the error messages. This is the code exactly as I try to compile it, This is the entire scetch directly from the seller. is something missing?

//YWROBOT
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
  lcd.init();                      // initialize the lcd 
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(3,0);
  lcd.print("Hello, world!");
  lcd.setCursor(2,1);
  lcd.print("Ywrobot Arduino!");
   lcd.setCursor(0,2);
  lcd.print("Arduino LCM IIC 2004");
   lcd.setCursor(2,3);
  lcd.print("Power By Ec-yuan!");
}

void loop()
{
}

Here are the errors I get

In file included from sketch_sep08e.ino:3:
C:\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:81: error: conflicting return type specified for ‘virtual void LiquidCrystal_I2C::write(uint8_t)’
C:\Program Files\Arduino\hardware\arduino\cores\arduino/Print.h:48: error: overriding ‘virtual size_t Print::write(uint8_t)’

I just noticed something that I believe is on the right track. in the third line of my code (one reply up) is my #include <LiquidCrystal_I2C.h> . I noticed that inside of the <> braces, that LiquidCrystal_I2C.h is not orange(orange, or red, I’m color blind so its hard to tell the difference). so is this a problem with the header file. I am pretty sure that I placed it in the library correctly, but I could be wrong.

Getting the address from the I2C_scanner is a prerequisite for proceeding further.

If it cannot find the address, you do not have an I2C interface, so nothing else matters.

Although it is for a 2016 LCD and you have a 2004, I know the test code that I cited works (for me) so given the correct I2C address and the descriptor corresponding to the board you have, labeled "LCM1602", should work at that step.

My suspicion is that the code from the seller may be a bit too generic, something he picked up somewhere else but hasn't tried - because he probably only sells Arduino stuff, rather than using it as is our interest.

I'll look into that code more closely when I get home from work - that is, I will actually try it myself. Have just been posting here in between cases and such. :smiley:

I will try to attach a picture of the back side of the LCD with the piggyback board just to be sure that I am on the same page. I just want to clarify that I upload the I2C_scanner to the arduino micro with my LCD connected to pins 2 and 3 and my 2 power wires to +5 and ground. with the serial monitor open, I am not seeing anything on the monitor, or the LCD. I just want to be sure that I am following the proper procedure.

kd7vea:
I just want to clarify that I upload the I2C_scanner to the arduino micro with my LCD connected to pins 2 and 3 and my 2 power wires to +5 and ground. with the serial monitor open, I am not seeing anything on the monitor, or the LCD.

When you say "I am not seeing anything on the monitor", if it finds no devices, it should show:

Scanning...
No I2C devices found

Scanning...
No I2C devices found

Scanning...
No I2C devices found

Scanning...
No I2C devices found

etc.

If it shows absolutely nothing, then the sketch is failing to load and run, and that is a deeper problem again.

OK, It appears that it loads because I get no error messages. I have loaded other sketches with no problems, so if the sketch is not loading, that seems very odd to me. could I be doing something wrong in the scanning process? do I need to do something with the com ports? I am really good at missing one little step. trust me, I do it all the time! it is almost 1:00 am and I have to head off to work at 6:00 am so we will pick this up tomorrow. thanks everyone

Paul__B:
.

My suspicion is that the code from the seller may be a bit too generic, something he picked up somewhere else but hasn't tried - because he probably only sells Arduino stuff, rather than using it as is our interest.

What a good argument for purchasing items from good, open-source suppliers which thoroughly test everything they sell to ensure compatibility & provide excellent online documentation & support of all of their products.....even if that means it costs an extra dollar or two.
:roll_eyes:

I was thinking about it, and what I dont understand is that the scanner does not pick it up. Regardless of the lcd header file , shouldnt the i2c scanner show something? I am not adding my possibly corrupt header file to the scanner, or should I be?

Which scanner are you using. I think if you are using the one from Nick, the script is all inclusive (don't need to add anything else).

And of course, if you do not have it wired to the right pins, It will not find anything. Did you decide which pins to use on the Micro?

Have you tried adjusting the contrast?

Ha Dave. I don’t think the contrast control will make any difference while trying to scan for I2C slave addresses. I used the scanner from Nick, and it worked really well.