Trying to use a 1602A 16x2 LCD Display on Higher Number MEGA pins

Parts:
Elegoo Arduino Mega2560 R3
1602A 16x2 LCD Screen

Wiring:
VSS - GND
VCC - 5v
V0 - Wiper pin of a 10k Ohm Pentometer connected to 5v and GND
RS - Mega Digital Pin 30
RW - GND
E - Mega Digital Pin 31
D4 - Mega Digital Pin 32
D5 - Mega Digital Pin 33
D6 - Mega Digital Pin 34
D7 - Mega Digital Pin 35
A - 5v
K - GND

Code

// Include the library code
#include <LiquidCrystal.h>

// Initialize the library with the numbers of the interface pins
const int rs = 30, en = 31, d4 = 32, d5 = 33, d6 = 34, d7 = 35;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

// Initialize the LCD screen size variables
const int numRows = 2;
const int numCols = 16;

void setup()
{
  // Set up the LCD's number of columns and rows:
  lcd.begin(numCols, numRows);

  // Print the Default LCD Message
  lcd.setCursor(0, 0);
  lcd.print("   Useless Box  ");
  lcd.setCursor(0, 1);
  lcd.print("      Mk.42     ");
}

void loop()
{

}

I used this exact same code with a different set of digital pins for LCD hookups to the Mega and it worked fine, I'm a bit confused about why it doesn't work on alternate digital pins. Does the screen need to use the PWM pins specifically?

I don't even get the test-squares when I have no code in the Mega at all, so clearly something is wrong, I just don't know what it is.

For reference, my previously used pins were
VSS - GND
VCC - 5v
V0 - Wiper pin of a 10k ohm pentometer connected to 5v and GND
RS - 7
E - 8
D4 - 9
D5 - 10
D6 - 11
D7 - 12
A - 5v
K - GND

Thank you for your responses.

I don't believe you.

The LCD should work on any digital pins. Note that your ? working example should connect RW to GND.

Check your wires.

David.

If you have no squares, then it's a power or contrast fault - get the squares first, then add the data lines.

Try adjusting the contrast.

Code works fine on my Mega with 1602 display. As David says, check your wiring.

And the contrast pot should be connected only to ground. It should act as a variable resistor not a potential divider.

groundFungus:
And the contrast pot should be connected only to ground. It should act as a variable resistor not a potential divider.

I'm working from this: In-Depth Tutorial to Interface 16x2 Character LCD Module with Arduino
That states to connect the 2 outer pins of the POT to +5 and GND, and the middle pin to V0 on the screen.
I will redo my wiring and check again.

Apparently the Pots that came with the kit I'm using went belly up, tried both of them, then ran V0 straight to ground. With it grounded I get the squares, and barely visible text.

I threw a 2.2k Ohm resistor in line with V0 and now it works perfectly. The pots must have been really cheap to die after only a few uses.

I don't believe you.

I would expect a single 270R resistor between VO and GND.

Experiment for best contrast between 120R and 470R. 2k2 seems an unlikely high value.

David.

I get good contrast on a couple displays that I have with a 1K resistor.

The connection of the pot to 5V and ground is a mistake from years ago that was propagated by people copying the original post that used the pot improperly. Paul has the whole story.

groundFungus:
Paul has the whole story.

:grinning:

groundFungus:
I get good contrast on a couple displays that I have with a 1K resistor.

The connection of the pot to 5V and ground is a mistake from years ago that was propagated by people copying the original post that used the pot improperly. Paul has the whole story.

The diagrams depicting the 3-wire (potentiometer) connection instead of the 2-wire (rheostat) came long before it became routine for anyone to post anything anywhere on-line.

Don

floresta:
The diagrams depicting the 3-wire (potentiometer) connection instead of the 2-wire (rheostat) came long before it became routine for anyone to post anything anywhere on-line.

So where were the said diagrams then?

So where were the said diagrams then?

I believe that you are about the same vintage as me so you should know the answer to that.

It is well known that you folks do just about everything backwards from us but surely electronic hobby projects existed in your area before the proliferation of the internet.

Don

This topic was automatically closed after 120 days. New replies are no longer allowed.