help connecting J204A to Mega2560 R3

Ok, have a 4x20 J204A LCD that im connecting to my Mega 2560 R3.

I have followed this tutorial

but also connected the backlight through a 470R resistor.

I'm fairly sure i have it wired up correctly (checked it multiple times).

This is my code

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

// initialize the library with the numbers of the interface pins
 //LiquidCrystal lcd(33, 31, 35, 37, 39, 41, 43, 45, 47, 49);
//LiquidCrystal lcd(33, 31, 43, 45, 47, 49);
LiquidCrystal lcd(33, 31, 43, 45, 47, 49);

void setup() {
   // set up the LCD's number of columns and rows: 
   delay(5000);
   lcd.begin(20, 4);
   // Print a message to the LCD.
   }

void loop() {
   // set the cursor to column 0, line 1
   // (note: line 1 is the second row, since counting begins with 0):
   lcd.setCursor(0, 1);
   // print the number of seconds since reset:
   lcd.print("hello, world!");
}

Yes, the pin assignment is a little weird, im using a breakout board and they are the easiest pins to solder too :stuck_out_tongue:
I assume the 6/10 pins that i use can be any pins on the Arduino, i don't need to use any SPI/PWM pins or anything?

I have even tried using all 8 data pins, this also does not work.

looking on the screen , i can see it 'refreshing' with the loop.

On each 'square' i can see horizontal lines running up each one randomly.

any ideas on what the problem could be?

 The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

Edit the above ; substitute your pin numbers. and post the edited version.

ok, i'll admit it... i'm an idiot!

Thank you for your reply, not sure how i did it but i had the pins for D4-D7 listed backwards in the code.

Just fixed it and the display is working correctly.

I would never do that..... XD

Just fixed it and the display is working correctly.

It may be 'working' correctly but you are not using it correctly in your present sketch.

The display does not need to be refreshed. Anything that you send to the display stays there until it is overwritten or until the power is removed.

The message "hello, world!" doesn't change and therefore, in the original sketch, it was sent to the display once, in setup().

The 'number of seconds since reset', in the original sketch, changes periodically and therefore is rewritten to the display each time around loop().

Don

later....

raschemmel:
I would never do that..... XD

Of course not... :smiley:

floresta:

Just fixed it and the display is working correctly.

It may be 'working' correctly but you are not using it correctly in your present sketch.

The display does not need to be refreshed. Anything that you send to the display stays there until it is overwritten or until the power is removed.

The message "hello, world!" doesn't change and therefore, in the original sketch, it was sent to the display once, in setup().

The 'number of seconds since reset', in the original sketch, changes periodically and therefore is rewritten to the display each time around loop().

Don

i am aware of this, i had it that way to simplify the code and make sure i didn't have something wrong.

i have since moved over to 'real code' where it is being used properly.

but, thanks for your advise anyway.