BLOG > Tutorial 13 for Arduino: Liquid Crystal Displays

I had initially planned to do an LCD tutorial a little further down the line, but there was very high demand for it, and I already had a circuit assembled for testing the new LCD that element14 sent me to evaluate. So, this seemed like an appropriate time to roll it out!

In this episode, I explain how communication works with most modern LCD character displays, I show the schematics and circuit required to talk to an LCD, and then I demonstrate it working using two demo programs.  The first program will create an animated progress bar using custom characters, and the second will leverage I2C and button debouncing knowledge from tutorial 7 and tutorial 2 respectively to create a real time temperature readout in both Celsius and Fahrenheit.  Download the source code, schematics, datasheets, and parts list below!

 

You can download the files associated with this episode here:

GNU GPL License Distributed under the GNU General Public (Open-Source) License.
Please Attribute and Share-Alike.

Dave Morgan has created a modified version of this code that works with the TMP36 sensor found in the Sparkfun Inventors Kit.  Download it here: MyRoomTempLCD.

93 comments

  1. Hi Jeremy, would you be able to help me with a problem im having? I will explain so you can decide. Im working with a common anode led dot matrix display and two 74HC595N shift registers. Im confident that I have wired everything correctly to my specific dot matrix display but when i upload the code to produce a heart(its from the book beginning arduino) all that happens is all the leds are light, albiet some are brighter than others. I have a schematic of my work and i am happy to attach the code..Please help me because im out of ideas on how to resolve the issue! If not, no worries, I know you’re busy!

  2. Hello, I haven’t been here for a quite while, and there are 3 new Arduino tutorials. Wonderful ! Thank You !

  3. Awesome!! I’ve never been to your site before. I’ve been playing with the idea of making a specific type of timer using Arduino and an LCD display. A friend of mine pointed me to this page. Your site is definitely getting bookmarked and visited often!! Good job!

  4. I tired to import Arduino in Processing. I followed the procedure that is outlined in “http://www.arduino.cc/playground/Interfacing/Processing”. When I tried to run the example in the above website, I got this error: “cc” does not exist. Can you help me with this?

      1. Thanks, I figured it out. I was trying to design a game. Now, I am trying to make it wireless. I followed your tutorial 9 on wireless. I was successful to program the Xbees. I tried to load a simple sketch to tes the wireless, I could not do it. The Serial Port in Tool Menu of Arduino IDE is grayed-out(not activated) I checked the Ports on Device Manage of Control Panel (Window XP), my Arduino Uno is mapped to COM4, but Arduino IDE does not recognize it. Have had a similar experience?

    1. I doubt the arduino would have enough processing power – I’ve never tried to interface with it like a screen like that, but that doesn’t mean it’s impossible.

  5. Hi,
    first i have to say, your tutorials are awesome! I’ve learned quite a lot here.
    Question: Do you know a good tutorial about graphic lcds? I want to use one
    in my projekt, but i have no clue how to program it^^

      1. they have indeed a minitutorial about glcds on their page.
        But its only for serial lcds.
        Mine is working now after some trying.
        Apart from that, it would be great if you do a tutorial
        using a glcd.

  6. Jeremy,

    I’m building a very big project at the moment and I need a lot of my arduino’s pins. Does it matter if I connect the display to normal I/O pins?! Or are there pins on the display that need PWM (I’m not sure if the LiquidCrystal library/LCD display needs them or not)?!

    Also thank you for your amazing tutorials! You are the reason I bought an Arduino in the first place!

  7. Hello Jeremy,

    I’ve tried printing to LCDs and one thing I noticed was that when you start counting from say 1 up to 20 and count down again, the second digit remains and will not clear. Is there any way to make this count down from 20, 19, …, 9, 8…1 instead of 20, 19, 18…10, 90, 80…10?

    Best regards!

  8. hello jeremy…i am in the last year student with the final year project…i am using arduino to build a 30 minutes timer but get confuse to it..do you have any previous post that tell about making timer using the arduino?

  9. Hi Jeremy,

    i’m making a project right using a Arduino Uno now and i must measure the temperature to but i must display the temperature on a Serial LCD. Can you give me some advices?
    Actually i must create a Breathalyzer and because the temperature is one of factors i must displying it to. I need some help.

    Tank you very mouch

  10. Hi Jeremy,
    Your tutorials really help those of us that do not understand electronics, but still want to get something done with the Arduino.
    I have some 4 digit 7 segment LED B08M04 displays that I would like to use with Arduino to show values with 2 fixed decimals. Can you please explain how to do this. Pins 1,3,4,5,6,8 are used with Pin 9 connected to pin 6.

    Cheers,

  11. Hi Jeremy,

    i really love to learn more from you,,and this days i planning to make a tester for vga cable which is connected to the lcd, if one of the wire is not present or damage and interchange the lcd will give information which wire and pin number is abnormal, the problem for the vga i need to check is has a 15 wire connected against the pin which is tottaly different with the vga cable you can buy from the local market. i really apreciated it alot for your help, i want to interface this project to my arduino duemilonove.

    thank you so much

  12. hi jeremy , those tutorials are really cool! thanks… hey , i wonder if you could helpme with a problem im having.
    im using arduino fio at moment, and well , basically, i want to show a message on the display (2×16), like you did in the tutorial. the differece is that i dont want to use a resistor or a potentiometer to adjust the constrast, i want to do it in digital way. it should be really easy i thought, but after i downloaded the code, the display didnt show me what i wanted. it started to show in the first row everything in black, i mean, all the little squares where the characters appear were full lighted. and the secod row the same but with a little less brigth.
    so I dont Know what im doing wrong!!!
    this is the code im running on the arduino:

    #include
    LiquidCrystal lcd(3,5,6,7,8,9);
    int vo = 2; //contrast adjustment
    int rw = 4; // read or write
    int ledp = 12; // led+
    int ledm = 13; //led-

    void setup() {

    lcd.begin(16, 2);
    Serial.begin(9600);

    pinMode(vo, OUTPUT);
    pinMode(rw, OUTPUT);
    pinMode(ledp, OUTPUT);
    pinMode(ledm, OUTPUT);
    analogWrite(vo, 50);
    digitalWrite(rw, LOW);
    analogWrite(ledp, 200);
    digitalWrite(ledm, LOW);

    }

    void loop() {

    lcd.setCursor(0,0);
    lcd.print(“hello”);
    }

    this is a bit urgent for me soo i will really apreciate you helpp!!!
    thanks.

  13. As for the TC74 temperature sensor, pin SDA is connected to analog pin#4 and SCL is connected to analog pin#5. Is TC74 internally program to connect to these two analog pins? If I use arduino Mega, what analog pins should i connect the SDA and SCL to? I connect SDA and SCL to analog pin 4 and 5 and it doesn’t work.
    It doesn’t work means it does not output the “temperature” to the LCD screen. Maybe, in Arduino Mega, pins SDA and SCL are designated to different analog pins.

  14. Hi Jeremy,
    I’m using an LCD shield Pro with an Arduino Uno R3 and I know I have everything wired correctly but when i attach the LCD it won’t stay light. I did notice that the the LCD is a little wabbly will this make any difference?

    1. Are you able to control the text at all? Is it just the backlight that’s not working? Your arduino might not be able to give it enough power.

  15. Jeremy,

    It’ll be great if you can do a tutorial on setting up a menu in the LCD. I’ve been trying to get mine working but the explanations available on the net does not explain it clearly for a newb like me.

    Hopefully it’s something you’ll consider in the future.

    Paul

  16. Good tutorial Jeremy, but I actually would be more interested in a serial LCD interface and how to get it working with an Arduino. I have found several good circuits on the Internet, but every time I try to get them to work, even with the modified libraries that the authors supply, I am unable to get it to do anything. The interface I am talking about is a backpack with a 74HC595 or other shift registers. I am probably going to have to buy the adafruit one rather than make one as I am having trouble getting it to work. In any case, it would be nice to see a tutorial along these lines if you ever get around to it.

  17. I’ve watched a couple of your tutorials and have come away with a better understanding of the Arduino, its programming language, and the possibilities this platform affords. Your grasp of the subject matter is much appreciated, as is your ability to articulate your ideas, and teach and inform.
    Thanks for a great series of tutorials (I’m sure I’ll watch them all).

  18. Hello Jeremy
    Thanks for your helpful tutorials.
    Can you please explain me the use of 10k pot here and can the same thing be done without the use the potentiometer?

    1. Yes, the pot is used as a variable resistive voltage divider for setting the contrast of the display. You can accomplish the same effect by using two resistors of the appropriate value.

      1. Hey Jeremy,

        Just a quick note. I managed to regulate the contrast using pin 9 (PWM) and set the value in the analogWrite to 90. That worked perfect for me.

        Thanks for your great tutorials. BTW, do you know if somebody have connected Arduino with some small graphics LCD – like 128×64 or similar?

        Evgeny

  19. Hi Jeremy,

    In your tutorial 13, the code have to be changed from lcd.write(0) to lcd.print((char)o), otherwise it won’t compile, i’ve found the answer here:http://arduino.cc/forum/index.php/topic,74666.0.html
    I know i have asked your help earlier and i am pretty happy that i found the solution by myself. I want to thank you for putting interesting tutorials online.

  20. i have try to do exactly like your tutorial but when i tried to upload it, error occur. it said that:
    D:\STUDY\embedded\arduino-1.0.1-windows\arduino-1.0.1\libraries\LiquidCrystal\LiquidCrystal.cpp: In member function ‘void LiquidCrystal::initSPI(uint8_t)’:
    D:\STUDY\embedded\arduino-1.0.1-windows\arduino-1.0.1\libraries\LiquidCrystal\LiquidCrystal.cpp:117: error: ‘SPI’ was not declared in this scope
    D:\STUDY\embedded\arduino-1.0.1-windows\arduino-1.0.1\libraries\LiquidCrystal\LiquidCrystal.cpp:120: error: ‘SPI_CLOCK_DIV2’ was not declared in this scope
    D:\STUDY\embedded\arduino-1.0.1-windows\arduino-1.0.1\libraries\LiquidCrystal\LiquidCrystal.cpp:124: error: ‘SPI_MODE0’ was not declared in this scope
    D:\STUDY\embedded\arduino-1.0.1-windows\arduino-1.0.1\libraries\LiquidCrystal\LiquidCrystal.cpp: In member function ‘void LiquidCrystal::spiSendOut()’:
    D:\STUDY\embedded\arduino-1.0.1-windows\arduino-1.0.1\libraries\LiquidCrystal\LiquidCrystal.cpp:403: error: ‘SPI’ was not declared in this scope

      1. jeremy.. thanks alot.. i found the solution.. =)
        i have a request.. can u make a tutorial about combining keypad with lcd? thanks again..

          1. All you have to do to solve it is to include this line of code before everything

            #include

            hope it helps
            -Kevin

          2. Ok… The website is not displaying the code correctly.
            Disregard my last comment.

            Here how you can solve it. After you have opened up the code in Arduino IDE, open the sketch menu in the menu bar, then Import library and click on SPI.

            Sketch-Import Library- SPI

            -Kevin

    1. I am currently having this exact problem with the same code on an UNO. Please let me know how you fixed this.

      Thanks.

  21. Jeremy,
    I have a couple DS18S20, digital thermometers and was wondering if one of them could be used in place of the TMP36 or TC74A0-5.0VAT? I am thinking that mine are digital and the others are analog. Is this the case? Thank you for all of your tutorials, I have thoroughly enjoyed them and learned a lot from you.

    Mike

    1. Hi Mike,

      I have a DS18B20 temp sensor and wondered if you managed to get some progress in using jeremy’s LCD – Temp tutorial with your sensor?

      I managed to get some output, but it is definitely not in celsius or fahrenheit

      -Gijs

  22. Hi Jeremy from Greece. You have been a very good Help especially for my Arduino projects.
    Besides that I am very interrested in the software you used to create your awesome intros of your tutorials…

    Sincerely,

    Nick

  23. Jeremy thanks for the tuturials especially on the debouncing and the program writing that went with it. I am just starting to learn writing Arduino programs and it helps to understand the writing format , especially the challenging ones, in the debounce program.

  24. We can see a program where you draw the schematics what kind of program is it? (On 14:36 in the video)

      1. Hi jeremy, I have downloaded both Eagle and Fritzing to my computer but none of them has the TC74 sensor. How did you find one to use in your schematic

  25. Hey Jeremy,

    Thanks for your excellent tutorials on Arduino. We struggled for a few days when interfacing the LCD with the Arduino but your tutorial helped us a lot.

    Your Youtube videos are of great help as well and better late then never, I subscribed your blog & your YT channel.

    Keep the great work coming !!!

    – Himanshu Sheth.

  26. Hey, Jeremy.
    I am planning to make a magnetic lock for my school project which consists of a numeric keypad and an LCD display. I’m just new in the world of Arduino and programming, so I don’t have much of a clue on how to start my program, or rather, I really have no idea. I am thinking that the LCD should display whatever that is being pressed in the keypad, and it should indicate whether if the input passcode is correct or not. Thanks in advance! More power!

  27. Hi I was hoping you could help me out something I want to make its a count down using a LCD when I Press a botton it starts to count down when it come to an end it would turn on a relay as I am new to arduino I can’t get the code to work would you HELP please

  28. Hey jeremy thanks for this nice tutorial. well i have a question that can we use hardware inturruppts for debugging purposes in this tutorial ??????

  29. Hi, I recently bought a parallax LCD with only 3 pins, no worries about that, I can print words to it, values etc… but when it comes to custom characters I have some questions, because I cant use byte arrays!!
    I can write custom characters to it but only like this:

    mySerial.write(251); //command to store the custom character 3

    mySerial.write(B10001); //and now I have to write 8 bytes to the lcd store
    mySerial.write(B01010);
    mySerial.write(B00100);
    mySerial.write(B01010);
    mySerial.write(B10001);
    mySerial.write(B01010);
    mySerial.write(B00100);
    mySerial.write(B01010);
    mySerial.write(12); //clear the screen
    mySerial.write(“character test: “);
    mySerial.write(3); //print character 3

    my question is why cant I make it like this:

    byte s[8] = { //create byte array (another question why is the number [8] for?? )
    B10001,
    B01010,
    B00100,
    B01010,
    B10001,
    B01010,
    B00100,
    B01010,
    };
    mySerial.write(12); //clear lcd screen
    mySerial.write(250); //store the character 2
    mySerial.write(byte(s[8])); //send the byte array with the 8 bytes values for the character
    mySerial.write(2); //write character 2

    Any ideas on how can I get this working??

    Thanks

  30. sir,
    can u help me out making a standalone arduino and give the input set-point using a keypad and display the current value, set value, Ton, Toff, and PID value in an LCD for a temperature control loop,,
    for the time being i m using LM35 temperature sensor and using the pin Ao of arduino

  31. HI
    I need help to get a code for displaying keypad digits so that every time key is pressed value is shown on next column. I tried this code

    Keypad customKeypad = Keypad( makeKeymap(Keys), rowPins, colPins, ROWS, COLS);
    LiquidCrystal_I2C lcd(0x38,16,2);
    void setup(){
    Serial.begin(9600);
    lcd.init();
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(“Enter Room No. “);

    }

    void loop(){

    int i;
    for(i=0;i<=2;i++){
    lcd.setCursor(i, 1);
    lcd.cursor_on();
    char customKey = customKeypad.getKey();
    if (customKey){
    Serial.println(customKey);
    lcd.print(customKey);

    }
    }
    }

    Need Help …………….
    Rajendera

  32. Hi Jeremy, excellent info, looking forward to more videos.

    I’m playing around with I2C interface to LCD (using PCF8574) and see various i2c libraries, all of which seem to work. There is the one from adafriut, from Francisco Malpartida, from Mario_H and from LiquidTWI by Matt Falcon (FalconFour) …. to mention a few.

    Have you checked out any of the above i2c LCD libraries and do you have any personal preferences ? I can’t make up my mind which library to use.

    Keep up the good work!

    thanks,

  33. Jeremy, any chance you can explain how to connect multiple lcd displays (16×2), and give an idea of how many displays can be connected? Arduino or RaspberryPi.

    Thanks!

  34. Hey Jeremy, I have connected my JHD 162A 16*2 lcd to my Arduino Uno exactly as u have shown in ur video and i have uploaded this code

    #include

    LiquidCrystal lcd(2,3,4,5,6,7);
    void setup()
    {
    lcd.begin( 16,2);
    lcd.print(“HELLO”);
    }
    void loop()
    {
    lcd.setCursor( 0,1);
    }

    What i’m able to see on the display is that the first row is showing only black boxes..I even tried the example code shown on arduino.cc website but faced the same problem again…..i wud be glad if u cud suggest a solution

  35. hi jeremy, how do I make the delay of the number I scritoo on the LCD with the kaypad? I write for example 12 with the kaypad and turn on the LED for 12 seconds. thanks in advance

  36. hey jeremy,love your tutorial,would love to know how the push button is used to change the display 4rm fahrenheit to celsius

  37. Hi… Can any one please help me up!!!

    I am new to the Arduino & I Was struck with a project, where I need to use 8-bit binary values.

    I can get 8-single bit binary output from the machine(1-from pin1, 0-from pin-2,…….), but I need to combine those into a single 8-bit binary output(e.g. 1011 0100).

    These might be simple but that helps me alot, so kindly reply soon to continue my internship

  38. Hi jeremy,

    I have done excatly what you did. But I still see nothing on my LCD. everything is true. What can by the problem? ty

  39. Unfortunately the “SparkFun Inventor’s Kit for Arduino”–link listed under your video above–has been retired and is no longer available for sale on the SparkFun website. The description and pictures are still listed for reference only.

  40. hi Jeremy,
    I have a probelm with operating the LiquidCrystal screen.
    I did exactly as you said but ny screen keep doing nothing.
    i see a row of black aquers and under it a blank row.
    the LCD seems to have enogh power ( i can see it when im cahngeing the potenztiometer)
    Do you have any idea whts wrong ?

    thanx very much,
    Danny

  41. Hi Jeremy, I need some help in interfacing the TFT LCD and a keypad. I am using Arduino Uno. I want to display what i pressed in the keypad on the LCD, how do i do that? Thanks in advance!

  42. I tried to connect my LCD to Ardunio Mega I know LCD Pin But I don’t know how to connect to mega I follow your codes but still couldn’t get result . let’s assume all pins on LCD is same as you explained for this video how can I initialize pins?

    thanks

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: