Go Down

Topic: Arduino Mega 1280 with LCD SG12864J4 (Read 6097 times) previous topic - next topic


I have started to play with the arduino a short while ago. However, I encountered an obstacle.
My arduino kit arrived with SG12864J4 LCD screen, and I am unable to get it to work. First, I tried wiring it via the tutorial even though I have a 20 pin connection, like that:

Then, I downloaded both libraries: GLCD v3 and ks0108, and I wired the arduino according to the guide which appears in glcd library. My LCD screen is located under type B boards.
I uploaded the ready-made software 'Hello World', but nothing happens. Not even get a backlight.

However, if I connect 5V and GND to pins 19 and 20, I only get a backlight.

Any ideas?

Thanks in advance


First, I tried wiring it via the tutorial ...

Which tutorial are you referring to?  You seem to be talking about a Graphical LCD yet your picture shows a Character LCD.



Jan 25, 2012, 07:07 pm Last Edit: Jan 25, 2012, 07:09 pm by prosorcerer Reason: 1
Thanks for the quick reply.

You are right, I am using a graphical LCD, but I tried the tutorial in the Arduino's learning section.

This is the page of my LCD screen:

I assume that current is passing since I attached a 220Ohm resistor and it heated up pretty fast. I don't have a multimeter yet.


I ran the GLCDdiags sketch which is supposed to run a test and verify everything is in order:

Diag Loop: 2
Initializing GLCD
GLCD initialization Failed: RESET wait Timeout (status code: 2)
Reported Arduino Revision: 1.0
GLCD Lib Configuration: glcd ver: 3 glcd_Device ver: 1 gText ver: 1
GLCD Lib build date: Mon Dec  5 01:50:07 CST 2011
GLCD Lib build number: 442
Panel Configuration:ks0108
Pin Configuration:ks0108-Mega
GLCD:ks0108 DisplayWidth:128 DisplayHeight:64
Chips:2 ChipWidth:64 ChipHeight:64
CSEL1:33(PIN_C4) CSEL2:34(PIN_C3)
RW:35(PIN_C2) DI:36(PIN_C1) EN:37(PIN_C0)
D0:22(PIN_A0) D1:23(PIN_A1) D2:24(PIN_A2) D3:25(PIN_A3)
D4:26(PIN_A4) D5:27(PIN_A5) D6:28(PIN_A6) D7:29(PIN_A7)
Delays: tDDR:320 tAS:140 tDSW:200 tWH:450 tWL:450
ChipSelects: CHIP0:(33,0x1, 34,0x0) CHIP1:(33,0x0, 34,0x1)
Data mode: byte

As you can see, GLCD initialization Failed: RESET wait Timeout (status code: 2).
What does this mean?


Your wiring is wrong. You're following the tutorial for a completely different type of LCD. The tutorial you're following is for a character based LCD and you have a graphical LCD.

Assuming your GLCD module is KS0108 compatible, you need to download this library an follow the instructions in the documentation. That will get you a circuit that should work, assuming you've not already damaged your GLCD panel.




Jan 25, 2012, 08:45 pm Last Edit: Jan 25, 2012, 08:47 pm by floresta Reason: 1
You're following the tutorial for a completely different type of LCD.

You really don't know that, but it is a good possibility.  He hasn't actually specified which tutorial he followed.

but I tried the tutorial in the Arduino's learning section.

Once again:  Which tutorial?  If I try to guess then the very best I can do is get the correct one.



A bit of explanation of the diags output.

The first thing the initialization code does is look for proper power status
of the glcd.
It looks at status bits that indicate that reset is complete and that the glcd
is not busy and is ready for initialization.

The error "RESET wait Timeout" means that after waiting more than
should be necessary the board "appears" to be stuck in reset.
I say "appears" because this is based on a status bit and if the wiring
is not correct, than the status information is not really valid.

Usually this type of error is from improper wiring.

I'm not sure how you have things wired but components should not heat up
(or at least not very much)
That is sure sign of something miswired and is definitely not a good thing.
Guessing on wiring is not good as miswiring can damage the glcd or arduino.
So if things are not clear it is best to ask before turning on the power.

Pay very close attention to the power connections and how the contrast
pot is wired. (The contrast pot wiring for a ks0108 is not the same as a hd44780)

As far as the other diag information, you can see that it prints the pin configuration.
It shows both the AVR pin # and the raw AVR port/bit value as well.
You can use this information wire up the glcd rather than the table if you like.

Each signal indicates the arduino pin that must be used for that signal.
So for example:
CSEL1:33(PIN_C4) CSEL2:34(PIN_C3)

Means that CSEL1 is on arduino pin 33
and CSEL2 is on arduino pin 34.

If you look at your datasheet then
CS1 is on glcd pin 15, so Arduino pin 33 would be connected to glcd pin 15.

This matches what is in the table for glcd "B" when using a mega:
If you look in the table at the "GLCD Function" column and scan down
to CSEL1 then look left to the number in the "Mega" column you will see a 33
and if you look right to the "Panel B" column you will see a 15
So that indicates that Arduino pin 33 is connected to glcd pin 15.

One other thing I've seen that has caused issues is mis identifying the pins on the mega.
Don't forget about the power pins along the top when you count down the Mega pin numbers
on the connector.

--- bill


Good afternoon. We need your help.
There Arduino Mega 2650 and a graphical LCD screen digitron SG12864j4(http://www.digitron.com.hk/sg12864j.htm).
I plugged it in just like in the manual(http://www.arduino.cc/playground/Code/GLCDks0108) Pinout B, found in the Arduino IDE library GLCD, uploaded an example ks0108example, but no data on the screen is not displayed, only the backlight is turned on.
What could it be? The screen is faulty?


Normally, it is best if you start you own thread for help on a particular problem rather than jump in the middle
of someone else's thread. The problems/issues are often similar yet different.
In this case since the OP seems to have vanished after a few responses, before the issue seems to have
been resolved, it's probably ok.

My suggestion is to run the diag sketch. That will provide additional information.
Then if things are still not working, you will need to post the diag output as well
as additional photos.
The photo you have is great but it isn't quite good enough to be able to see all the wires
and where they are connected.

--- bill

Go Up