Home > Arduino > Arduino Mega and ILI9320 Display

Arduino Mega and ILI9320 Display

Hi everybody.
Last week I started making a ILI9320 library for the Arduino Mega, as I was hoping it would work with my 2.8″ Display (with a ILI9320 controller of course).
After a couple of hours I’ve made the code doing the timings correctly, and then I made a simple PutPixel routine. It worked, so I continued to make a Text function, and afterwards different polygons commands.
When I had made all these commands I began to optimise everything, as the Arduino isn’t running fast enough, so a complete screen clear takes about 2-3 second. After a couple of days optimizing, I got it down to 1 second, and other commands such as rectangle was alot faster. I had also made a function so I could “scroll” the screen – which is descriped in the ILI9320 datasheet!

Here you can see some pictures of the final version, and download the code here: Arduino Mega and ILI9320 code

Arduino Mega and a 2.8-inch display (ILI9320)

A close up of the Hello World screen

And here is a user posted video of the library in action on an ATMEGA16A.
Thank you to ‘Maarten van ingen’ for showing us this video.

  1. September 5th, 2010 at 15:15 | #1

    thank you very much for sharing your experinece with us. Is it possible to have connection diagram also? thank you very much in advance, reha

  2. September 6th, 2010 at 10:21 | #2

    I don’t have any connection diagram, as I’ve just wrote the connections in the top of the code.
    It takes a lot longer making a connection diagram, and when the circuit isn’t bigger than this, I don’t see the need to make one!

    This is the connections:
    Arduino Pin -> LCD Pin
    22 -> DB0
    23 -> DB1
    24 -> DB2
    25 -> DB3
    26 -> DB4
    27 -> DB5
    28 -> DB6
    29 -> DB7
    30 -> RS
    31 -> CS
    32 -> WR
    33 -> RD
    34 -> RESET

  3. Jemmi
    October 20th, 2010 at 12:14 | #3

    I also am working with one of these displays but some things aren’t clear to me…

    The display I have offers 16 bit or 8 bit with the 8 bit using db8-15 and not db0-7. But when I wire it up as you have shown, I get nothing when in 8 bit or 16 bit mode. But when I wire it as it should be for 8 bit version, I get cycling brightness levels at least… but nothing more. What I am reading is that in 8 bit mode I need to use the latch which is pin LE (Latch Enable). Which I added in to your library in the setup to take that pin high but this is again just the cycling brightness levels… Any idea what I might have wrong? It seems to want to work, but won’t. And what do you have with the Enable pin… do you leave it floating? Didn’t seem to make a difference for me as it still cycles brightness….

  4. October 28th, 2010 at 09:57 | #4

    Hi Jemmi.
    Yes I’m sorry, I’ve just checked the datasheet, and when the display is in 8-bit mode, you should use DB8-15.
    About the cycling brightness, I’ve seen those things on my display too. After some code changes it was fixed, but suddenly it appeared again. So I wasn’t sure if it was a code problem, or a cable problem.


  5. peter
    December 31st, 2010 at 17:16 | #5

    thanks for this information. Could you please let me know what model of color LCD this actually is? do you know of a slightly smaller version, say 2″, that is compatible with your code?
    (the 2.8″ display is a bit too large for my project).

  6. January 1st, 2011 at 15:17 | #6

    Hi Peter.
    This is a display I found on eBay, with the ILI9320 display controller.
    ILI9320, ILI9325 and ILI9328 is mostly the same, and requires only some small changes in the code. You can get 2.4″ displays on eBay too, but I haven’t seen any smaller with this resolution and chip.
    If you need a display even smaller, I can recommend the Nokia 6100 or 6610 display, which is a 128×128 pixel display.

    Best Regards
    Thomas Jespersen

  7. March 18th, 2012 at 23:03 | #7

    Hi Thomas, thanks a lot for your Library, it´s the only one that´s works whit my Chinnese Screen thanks… but I have a little trouble and I don´t know wnat I can do wrong… I can´t make appears text in the Screen, I leave the code like you have made the library, but I don´t have any character or string in the Screen…. I try to put an Hexadecimal font of Commodore 64… but whitout success… This library it´s the final release… or you have the same whit little modifications…

    Thanks in advance, and how I say again it´s very easy to use… and well the only one that´s works for me…

    Kinds Regards,
    Iván J.

  8. March 22nd, 2012 at 11:30 | #8

    Hi Iván.
    I am sorry, but could you try to explain in at little more details what problem you are having.
    If I understand you, you are having troubles with the Text generating function. Are you using the code I made and uploaded “as is”, or have you made any changes to the font file?

    The uploaded file is always the latest one.

    Best Regards
    Thomas Jespersen

  9. March 23rd, 2012 at 05:42 | #9

    @Thomas Jespersen
    HI Thomas, yes perhaps my english sometimes not it´s enough…

    Well my trouble it´s , I can´t see text in the screen, I leave the example, like it´s by default, but I can see “Hello Word” text in the screen, I don´t know because this happends…

    I only think my screen are 2.2 inches… perhaps can be this…

    Thanks in advance…

  10. March 23rd, 2012 at 11:01 | #10

    Dear Iván.
    Which kind of display are you using. You said it was a chinese display, but are you sure it is the ILI9320. It is possible to get other displays with other controllers whose function a similar to the ILI9320, but the x/y-offset address is a lot different.
    The ILI9325 is a common display controller too, but as it is using another register address for the pixel offset, it wouldn’t work right with the pixel setting routine.

    Have you tried setting just a single pixel? Does that work?
    What about drawing a rectangle or a line?

    Best Regards
    Thomas Jespersen

  11. ivan
    March 23rd, 2012 at 15:09 | #11

    HI Thomas, I´m not sure 100% about the if the ILI it´s 9320… but I can tell you, I can draw rectangles, lines pixels, and well I make a simple routine for draw circles… the pixel works very fine…

    I think to make something myselfs, for write text, whit some hexadecimal word creator, but I´m not a C programmer, and I don´t know how do it…

    Don´t care a lot, I think not it´s a great trouble, if I can draw a only one pixel, I can draw anything, I hope 🙂

    Thanks in advance for all your help…

    Kinds Regards,
    Iván J.

  12. March 23rd, 2012 at 16:14 | #12

    Ahh, Now I think I know what is causing your problems.
    Let me know whether or not you are using the latest Arduino 1.0 version? The font part may not be supported well in this version as a consequence to the changes in the standard libraries.
    Could you try and download an older version of the Arduino IDE and see if it then works?

  13. ivan
    March 23rd, 2012 at 19:30 | #13

    Hi Thomas, thanks a lot, now Works… but only a one more thing…

    Can you tell me the exactly version of the Arduino IDE… I try whit the 0017 and 0021, and I have an extrange error, the letters appears in inverse Mode, very corious effect, but the strings apperars in screen , this it´s the most great important step.

    Thanks again, for your very desisnterested help…

    1K thanks…

    Iván J.

  14. March 25th, 2012 at 01:37 | #14

    I am sorry, but unfortunately I don’t remember the IDE version I used at that time. But I am sure it was higher than 0017.
    Please have a go with 0021, does it work properly in there?

    To get it working in the new IDE I think you should have a look at the PROGMEM of the Fonts. I think this is where it has to be changed!

    Best Regards
    Thomas Jespersen

  15. ivan
    March 26th, 2012 at 14:59 | #15

    HI Thomas, ok, don´t care… you make all too much, thanks in advance…

    I try to look this you tellme about Progmem…

    Thanks in advance for all your help, and ofCouse, about you fantastic library, whitout them, I can´t use my Chinesse LCD, thanks a lot.

    Iván J.

  16. mentalthink
    April 14th, 2012 at 16:26 | #16

    Hi thoma I´m Ivan again, I have good news about the inverse letters… Only a little trick

    In the function yu wrote, called DrawChar, in those lines
    if (p & m)

    change this line //LCD_PutPixel(x + xx, y + yy, color); for :
    LCD_PutPixel( x+xx, yy-y, color);

    whit this little change the lleters appears ok… almost for me…

    Thanks again for your library…

    Iván J

  17. April 14th, 2012 at 16:31 | #17

    Oh, I didn’t know you were talking about inversed letters.
    Regarding this issue there is multiple ways to fix it. One of them is the one that you found.
    Another one would be to change the pixel writing order of the LCD controller itself. This is set in one of the LCD registers.
    Please refer to the “8.2.6. Entry Mode (R03h)” chapter of the ILI9320 datasheet.


  18. Radek
    June 25th, 2012 at 08:52 | #18

    Hi Thomas, I need some advice – help, I have display ILI 9320 with olimex stm32-LCD, but there is in 16bit data, what changes I should do to make it work with your library?

  19. June 25th, 2012 at 18:38 | #19

    Hi Radek.
    To make the library work in 16-bit mode the main changes is to be made in WriteIndex and WriteData.
    In those routines the writing cycle should be combined into ONE 16-bit writing cycle instead of the TWO 8-bit writings.
    I don’t think any other changes would be required to get it running, except for the pin declarations (making the other 8-bit output too).

    Best Regards
    Thomas Jespersen

  20. Radek
    June 26th, 2012 at 08:20 | #20

    Thanks a lot. I’ll take a look on it.

  21. Maarten van Ingen
    October 29th, 2012 at 22:12 | #21

    I have adapted this source code a little to run on a standalone atmega16a without the need of the Arduino libs.
    My screen runs on 16bit mode so I have changed the source to only run in 16bit mode.

    If anyone is interested please let me know.

    I have made a little video what it looks like.

  22. November 4th, 2012 at 11:24 | #22

    @Maarten van Ingen
    Thanks for the video – looking good.
    Would it be OK with you if I posted this video in the blog post above to show the demo?
    Also, we would be very interested in getting the source code and add a download link below the video.

    Regards Thomas

  23. Maarten van Ingen
    November 9th, 2012 at 18:51 | #23

    @Thomas Jespersen

    Posting of the video is okay 🙂
    I will make a better one soon. Got the TP working (TSC2046E) but it dims the backlight for some reason.
    I will cleanup the code somewhat and put it online asap 🙂

  24. Barry
    December 26th, 2012 at 16:20 | #24

    Have you had any luck getting this working using SPI?



  25. December 28th, 2012 at 13:55 | #25

    Hi Berry.
    No, not yet. We haven’t tried using SPI on these larger displays due to the then VERY slow refresh rates.
    We have only been using SPI interface for displays with a resolution of 128×128 or less, such as the Nokia 6610 Knock off

    Merry Christmas
    Regards Thomas

  26. Maarten van Ingen
    January 15th, 2013 at 22:37 | #26

    @Thomas Jespersen

    Hi Thomas,

    I finally got some time to upload the source code.
    It is very unclean and not my best lines of code but hey, it works 🙂
    It can be found here: https://www.nhimf.org/index.php/downloads/viewdownload/3-sources/2-ili9320-c


  27. January 29th, 2013 at 02:01 | #27


    I bought this item http://fave.co/Ydfa2D which contains an ILI9320 and touch screen controller but the schematic and page said its wired only for SPI for both. I am trying to get it to work with an Arduino with no success so far…anybody use this or could offer help? I just tried to read out one register to see if I am doing things correctly and I just get back 0’s…

  28. January 29th, 2013 at 02:29 | #28

    I was going to try that code you listed (Maarten) but its not for an ATMEGA328 on an Arduino.

  29. Maarten van Ingen
    February 5th, 2013 at 08:25 | #29

    @Salman Sheikh
    Nope, my source code is for an atmega16a standalone. It will not work on an Arduino most likely.
    If you want to run in on an Arduino you should use the original code from Thomas which is linked in the article.

  30. May 1st, 2013 at 07:22 | #30

    i need to this sketch

  31. May 24th, 2013 at 21:13 | #31
  32. Pankaj Gabale
    June 13th, 2014 at 07:11 | #32

    Can I get the code for graph display on ili9320 by using UNO please..??

  33. June 27th, 2014 at 15:47 | #33

    @Pankaj Gabale
    The problem with the Arduino UNO and driving these parallel LCD displays is the limited amount of pins. It is possible though, but it won’t leave you with many pins for other periphirals.

    In general I recommend you to take a look at this very thorough LCD driver library for the Arduino: http://www.henningkarlsen.com/electronics/library.php?id=51
    But please have in mind with the number of pins and the limited RAM available on the ATMEGA328 as well.
    The pin-connections are described here: http://www.geeetech.com/wiki/index.php/2.4%22TFT_LCD

    Regards Thomas

  1. July 1st, 2010 at 10:58 | #1