Arduino newbie needs advice on port for comms with ks0108 glcd

Hi all,

This is my first post, so first I should introduce mself. I am new to Arduino but not new to microcontrollers, basic electronics or programming. My first Arduino, a Nano 3.0 will arrive shortly (I like to prototype on breadboards).

For my first project (after making an led blink) I have a circuit and some working code to port over from another type of uc. I need more speed and am hoping Arduino will provide that because the language is compiled rather than interpreted.

This project involves a graphic lcd (128x64) with ks0108 controller(s). With my current uc, I am using an entire 8 bit port to transfer data, plus 4 other lines for control. I am aware there is a library for this type of lcd, but I don't need to draw text or circles, I just need bit/pixel level access that is fast and efficient.

Once the prototype is working on the nano, I would like to use the nano as isp to move the code to a 28 pin dip atmega328 for the finished article.

Looking at the available ports on the 328, I can't see one where all 8 pins are available and not used by other critical functions like serial programming/debug, crystals etc.

So I need some advice as to feasability and the best approach to take please.



My advice is first make it work, then find whether it is fast enough, then (if necessary) look for ways to make it faster. By the time you're hitting the hardware ports directly you're losing a lot of the benefit of the Arduino framework and runtime library, and you should only resort to that if and when necessary.

Thanks for the response Peter. To "first make it work" I am going to need to find some approach or other. How would you suggest I organise comms between the nano and the lcd? The data my code will generate is already in the form of packed bits which I need to turn into pixels.

Hi again,

I have been reading up on the glcd library here:

Here are the pin/port mappings for the Arduino m328 processor:

Port B 8-13 Port C 14-19 (the analog pins) Port D 0-7 (note 0 and 1 are used by hardware serial)

While any Arduino pin can can be used for any glcd data pin, using Arduino pins that are all in the same port and that are in consecutive bit order will give slightly higher performance. The default pin assignments for the glcd data pins are assigned to take advantage of this optimization.

So will the fact that (if I use the default mappings) the h/w serial pins are used, I won't be able to use the terminal for debugging?

I guess I could use 2 other pins initially and when everything is working well, change back to using the full port for extra performance.



I also have a 328 Nano V3 and a 128x64 KS0108 display.

I would like to know what I have to modify in which files to get this display with the glcd libraries to work with my Nano board. It doesn't seem obvious from the documentation. Do I modify the ks0108_Manual_Config.h file? I have tried this but it doesn't work and I still have garbage on the screen.



Hi Nick,

I never did get around to making use of the glcd library for my application. The advantage would have been that the code could have been more easily ported to other types of glcd controller. But apart from that, the library presented more problems than it solved. It just wasn't appropriate for my application. I stuck to using digitalWrite and, with a bit of optimisation, its fast enough.

My application, by the way, is Conway's Game of Life, with each individual glcd pixel representing a cell. The update rate for the 128x64 grid averaging around 10 updates per second, a bit more when the grid is stable and sparsely populated, a bit less when very "busy". So no text or other shapes needed.

I may get around to further optimisations such as trying the fastDigitalWrite library (macros).