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
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 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:
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.
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.
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.