how to test lcd display 16x2 for sale
If you fear you"re lost in unknown resistance land, my LCD worked best when the 10.7k (max resistance) pot has 9.888k between + and LCD"s "V0" and .828k between - and LCD"s "V0".
LCD Display Modules└ LEDs, LCDs & Display Modules└ Electronic Components & Semiconductors└ Electrical Equipment & Supplies└ Business & IndustrialAll CategoriesAntiquesArtBabyBooks & MagazinesBusiness & IndustrialCameras & PhotoCell Phones & AccessoriesClothing, Shoes & AccessoriesCoins & Paper MoneyCollectiblesComputers/Tablets & NetworkingConsumer ElectronicsCraftsDolls & BearsMovies & TVEntertainment MemorabiliaGift Cards & CouponsHealth & BeautyHome & GardenJewelry & WatchesMusicMusical Instruments & GearPet SuppliesPottery & GlassReal EstateSpecialty ServicesSporting GoodsSports Mem, Cards & Fan ShopStampsTickets & ExperiencesToys & HobbiesTravelVideo Games & ConsolesEverything Else
These displays are straightforward to use and are a great way to provide a user interface on many projects where you need more info than simple LED indicators or 7-Segment displays can provide since these are full alphanumeric displays with 2 lines of 16 characters each. For an interactive display, pairing this type of display with a rotary encoder to navigate and select menu items on the display can provide a very nice user interface.
The display is composed of a 16 character x 2 line LCD display with a blue backlight and white characters. Each of the characters are composed of a 5 x 8 dot matrix for good character representation.
The backlight has a potentiometer for adjustment of the contrast of the display for best viewing. If the potentiometer is turned too far in one direction or the other, the display will appear blank or solid squares will appear instead of characters. If this happens, just fiddle with the adjustment until it gives the best display.
Note: The non-uniformity in the picture is due to the protective film covering the display playing a trick on the camera. The display has nice uniformity.
This display incorporates an I2C interface that requires only 2 pins on a MCU to interface with and it has good library support to get up and running fast. The I2C interface is a daughter board attached to the back of the LCD module.
If you need to adjust I2C address to avoid a conflict, this can be done on the I2C adapter board on the back of the module. There are 3 address jumper locations marked A0, A1, A2. Normally these lines are pulled high. If you bridge these pads, it grounds that address line. If you were to bridge all 3 to ground, the address would be 0x38 (or 0x20) depending on which version you have. The range of all possible addresses spans from 0x38 – 0x3F or 0x20 – 0x27
These are good quality modules and should be in the parts bin of any hobbyist. Because of the interactivity they provide, they are both fun to play with and useful for more serious projects.
We also offer the raw 16×2 displays without the I2C interface. Those have a parallel bus interface that requires many pins on the MCU to control. For most applications it is generally easiest to stick with the I2C interface version like this one.
Do you want your Arduino projects to display status messages or sensor readings? Then these LCD displays can be a perfect fit. They are extremely common and fast way to add a readable interface to your project.
This tutorial will help you get up and running with not only 16×2 Character LCD, but any Character LCD (16×4, 16×1, 20×4 etc.) that is based on Hitachi’s LCD Controller Chip – HD44780.
When current is applied to these crystals, they become opaque, blocking the backlight that resides behind the screen. As a result that particular area will be dark compared to the others. And this is how the characters are displayed on the screen.
True to their name, these LCDs are ideal for displaying only text/characters. A 16×2 character LCD, for example, has an LED backlight and can display 32 ASCII characters in two rows of 16 characters each.
If you look closely you can see tiny rectangles for each character on the display and the pixels that make up a character. Each of these rectangles is a grid of 5×8 pixels.
The good news is that all of these displays are ‘swappable’, which means if you build your project with one you can just unplug it and use another size/color LCD of your choice. Your code will have to change a bit but at least the wiring remains the same!
Vo (LCD Contrast) controls the contrast and brightness of the LCD. Using a simple voltage divider with a potentiometer, we can make fine adjustments to the contrast.
RS (Register Select) pin is set to LOW when sending commands to the LCD (such as setting the cursor to a specific location, clearing the display, etc.) and HIGH when sending data to the LCD. Basically this pin is used to separate the command from the data.
R/W (Read/Write) pin allows you to read data from the LCD or write data to the LCD. Since we are only using this LCD as an output device, we are going to set this pin LOW. This forces it into WRITE mode.
E (Enable) pin is used to enable the display. When this pin is set to LOW, the LCD does not care what is happening on the R/W, RS, and data bus lines. When this pin is set to HIGH, the LCD processes the incoming data.
D0-D7 (Data Bus) pins carry the 8 bit data we send to the display. For example, if we want to see an uppercase ‘A’ character on the display, we set these pins to 0100 0001 (as per the ASCII table).
Now we will power the LCD. The LCD has two separate power connections; One for the LCD (pin 1 and pin 2) and the other for the LCD backlight (pin 15 and pin 16). Connect pins 1 and 16 of the LCD to GND and 2 and 15 to 5V.
Most LCDs have a built-in series resistor for the LED backlight. You’ll find this near pin 15 on the back of the LCD. If your LCD does not include such a resistor or you are not sure if your LCD has one, you will need to add one between 5V and pin 15. It is safe to use a 220 ohm resistor, although a value this high may make the backlight a bit dim. For better results you can check the datasheet for maximum backlight current and select a suitable resistor value.
Next we will make the connection for pin 3 on the LCD which controls the contrast and brightness of the display. To adjust the contrast we will connect a 10K potentiometer between 5V and GND and connect the potentiometer’s center pin (wiper) to pin 3 on the LCD.
That’s it. Now turn on the Arduino. You will see the backlight lit up. Now as you turn the knob on the potentiometer, you will start to see the first row of rectangles. If that happens, Congratulations! Your LCD is working fine.
Let’s finish connecting the LCD to the Arduino. We have already made the connections to power the LCD, now all we have to do is make the necessary connections for communication.
We know that there are 8 data pins that carry data to the display. However, HD44780 based LCDs are designed in such a way that we can communicate with the LCD using only 4 data pins (4-bit mode) instead of 8 (8-bit mode). This saves us 4 pins!
8-bit mode is much faster than 4-bit mode because it takes half the time. In 8-bit mode you write the data in one go. Whereas in 4-bit mode you have to split a byte into 2 nibbles and perform two write operations.
4-bit mode is often used to save I/O pins. However, 8-bit mode is best used when speed is required in an application and there are at least 10 I/O pins available.
The sketch begins by including the LiquidCrystal library. The Arduino community has a library called LiquidCrystal which makes programming of LCD modules less difficult. You can find more information about the library on Arduino’s official website.
First we create a LiquidCrystal object. This object uses 6 parameters and specifies which Arduino pins are connected to the LCD’s RS, EN, and four data pins.
In the ‘setup’ we call two functions. The first function is begin(). It is used to specify the dimensions (number of columns and rows) of the display. If you are using a 16×2 character LCD, pass the 16 and 2; If you’re using a 20×4 LCD, pass 20 and 4. You got the point!
After that we set the cursor position to the second row by calling the function setCursor(). The cursor position specifies the location where you want the new text to be displayed on the LCD. The upper left corner is assumed to be col=0, row=0.
There are some useful functions you can use with LiquidCrystal objects. Some of them are listed below:lcd.home() function is used to position the cursor in the upper-left of the LCD without clearing the display.
lcd.scrollDisplayRight() function scrolls the contents of the display one space to the right. If you want the text to scroll continuously, you have to use this function inside a for loop.
lcd.scrollDisplayLeft() function scrolls the contents of the display one space to the left. Similar to above function, use this inside a for loop for continuous scrolling.
If you find the characters on the display dull and boring, you can create your own custom characters (glyphs) and symbols for your LCD. They are extremely useful when you want to display a character that is not part of the standard ASCII character set.
As discussed earlier in this tutorial a character is made up of a 5×8 pixel matrix, so you need to define your custom character within that matrix. You can use the createChar() function to define a character.
To use createChar() you first set up an array of 8 bytes. Each byte in the array represents a row of characters in a 5×8 matrix. Whereas, 0 and 1 in a byte indicate which pixel in the row should be ON and which should be OFF.
CGROM is used to store all permanent fonts that are displayed using their ASCII codes. For example, if we send 0x41 to the LCD, the letter ‘A’ will be printed on the display.
CGRAM is another memory used to store user defined characters. This RAM is limited to 64 bytes. For a 5×8 pixel based LCD, only 8 user-defined characters can be stored in CGRAM. And for 5×10 pixel based LCD only 4 user-defined characters can be stored.
Creating custom characters has never been easier! We have created a small application called Custom Character Generator. Can you see the blue grid below? You can click on any 5×8 pixel to set/clear that particular pixel. And as you click, the code for the character is generated next to the grid. This code can be used directly in your Arduino sketch.
Your imagination is limitless. The only limitation is that the LiquidCrystal library only supports eight custom characters. But don’t be discouraged, look at the bright side, at least we have eight characters.
In setup we need to create custom character using createChar() function. This function takes two parameters. The first parameter is a number between 0 and 7 to reserve one of the 8 supported custom characters. The second is the name of the array.
Grove - 16 x 2 LCD is a perfect I2C LCD display for Arduino and Raspberry Pi with high contrast and easy deployment. 16x2 means two lines and each line has 16 columns, 32 characters in total. With the help of Grove I2C connector, only 2 signal pins and 2 power pins are needed. You don"t even need to care about how to connect these pins. Just plug it into the I2C interface on Seeeduino or Arduino/Raspberry Pi+baseshield via the Grove cable. There won"t be complicated wiring, soldering, worrying about burning the LCD caused by the wrong current limiting resistor.
The Grove - LCD RGB Backlight has been well received since its inception. Based on customer feedback, now, we bring more cost-effective monochrome backlight derivative for you.
Except for RGB backlights, these three products are almost identical to the the Grove - LCD RGB Backlight, they are all 16 characters wide, 2 rows with high brightness backlight.
An introduction of What is a Grove - 16 x 2 LCD and How does it work is strongly recommended reading ahead if you are not familiar with it. Please visit our
The platforms mentioned above as supported is/are an indication of the module"s software or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library.
NotePlease plug the USB cable gently, otherwise you may damage the port. Please use the USB cable with 4 wires inside, the 2 wires cable can"t transfer data. If you are not sure about the wire you have, you can click here to buy.
The first version of Grove - 16 x 2 LCD series does not have a built-in pull-up resistor, nor does it provide a pad to solder the optional pull-up resistor. We have redesigned the module, and the new version has built-in pull-up resistors.
If you have an older version on your hand, you can solder a 10kΩ DIP resistor yourself on the back pad of the Grove connector. Please follow the picture below, solder a 10kΩ DIP resistor between VCC and SCL pins and a 10kΩ DIP resistor between VCC and SDA pins.
The Grove - 16 x 2 LCD shares the same library with the Grove-LCD RGB Backlight. Their usage is almost the same, except that the Grove - 16 x 2 LCD does not support the RGB color API, such as setRGB().
2). Open it in your computer by click the HelloWorld.ino which you can find in the folder XXXX\Arduino\libraries\Grove_LCD_RGB_Backlight-master\examples\HelloWorld, XXXX is the location you installed the Arduino IDE.
Since the Grove - 16 x 2 LCD series are all monochrome backlight, you need to comment out the RGB color related code. In the demo code above, i.e., line 6 and line 17.
Step 2. Make sure that the ArduPy firmware contains the Grove - 16 x 2 LCD ArduPy library using the following commands. For more information, please follow here.
Step 4. Save the ArduPy-LCD1602.py in a location that you know. Run the following command and replace
Range tests made easy with the RE-Mote and LCD:Reduce the number of equipment and preparations required for field testing (2.4GHz and 868MHz), pack everything you need in your hand.
The CFA533-***-KC series is a 16x2 I2C LCD with keypad. The I2C interface allows you to use just two lines (SDA & SCL) to have bi-directional communication with the I2C LCD. Other devices can also share those two I2C control lines with the LCD. Only 4 wires are needed to connect this I2C LCD: power, ground, SDA (I2C Serial DAta) and SCL (I2C Serial CLock).
The CFA533 can run on 3.3v to 5.0v directly, with no changes needed, so you do not need to do any level translation between your embedded processor and the I2C LCD. Simply power the CFA533 from the same supply as your processor and the I2C signal levels will match up.
Using only one address on your I2C bus, you can add all the elements that you need for your front panel. The CFA533 I2C LCD can also read up to 32 DS18B20 digital temperature sensors, giving you an easy way to integrate temperature sensing over the I2C bus. No additional firmware or pins are needed on the host system.
This CFA533-TFH variant features crisp dark letters against a white, backlit background. The keypad has a matching white LED backlight. Since the LCD is a backlit positive FSTN, the CFA533-TFH I2C LCD is readable in direct sunlight, as well as complete darkness.
This 2×16 character LCD Module with BLUE Backlight uses an I2C interface to communicate with the host microcontroller. This budget-conscious LCD is used on projects requiring the display of text, data, or ASCII characters of all types. Connect to Vcc, Gnd, SDA (serial data line), and SCL (serial clock line). This is a 5VDC device and will be found on the I2C bus at address 0x27 / 0x3F.
It appears that you installed it using a zip file downloaded from the github repository which created a directory with the incorrect name. Not only is it more difficult to install from a zip file than using the library manger network install capability, but having a library improperly installed can cause issues in the future when updating the library.
Installing from a zip file is not the recommended way to install the hd44780 library unless you are using an IDE prior to 1.6.2 which I would not recommend using and I assume you are not using.
Use the library manager to install the hd44780 library from the network directly, that way the library gets installed in the proper location with the proper name.
The hd44780 library can auto locate the i2c address and then auto detect the pin mappings used by the backpack and all the hd44780_I2Cexp examples use this capability.
An easy way to add a simple visual interface to your project is by using an LCD Nanoshield. With it, you can display two lines of text with up to 16 characters. That allows you to show text messages or sensor data to the user, for example.
The internal LCD controller is compatible with the HD44780 chip from Hitachi, a de facto standard in the market for this kind of LCD. This is the same standard used in the LCD library that comes with the Arduino IDE.
The easiest way to use the LCd Nanoshield with an Arduino is to use the Base Board Uno or the Base Board L Uno. You just need to snap the boards together and upload our sample code to verify it"s working (see the code samples section below). This type of connection can be used with Arduino UNO, Mega R3, Duemilanove, and similar boards (contact us if you have questions about compatibility with other versions). The picture below shows how the final assembly looks like.
It is also possible to connect the LCd Nanoshield to our Arduino-compatible microcontroller board, the Base Boarduino. The connection is done in the same way as with the Base Board, as shown in the picture below. You just need to snap the boards together and upload our sample code to verify it"s working (see the code samples section below).
By using the Mini Terminal Nanoshield, it is possible to securely connect the LCD Nanoshield to an Arduino equipped with a Base Board or to a Base Boarduino. This connection uses only five wires, and is useful when the LCD needs to be mounted away from the Base Board – for instance when if must be mounted on a panel or case. The diagram below shows how to make that connection.
The LCD is equipped with a backlight that can be controlled via software by using the backlight() and noBacklight() methods in our Nanoshield_LCD software library.
Note: with the backlight on, the power consumption of the board is relatively high, and the voltage regulator can get quite hot when the system is powered from an external power supply. Don"t worry however, since the board and the components were designed to operate with much higher temperatures without a risk of overheating (but probably you fingers weren"t, so beware). For applications where the ambient temperature is consistently higher than 50ºC and there is no airflow, we recommend use of an external power supply with a maximum voltage of 9V, or our PowerLDO Nanoshield.
Power supply: the board power is supplied via the VIN and VCC pins: VIN is optional but VCC is required. The recommended voltage range for the VIN pin is 7 to 12V (absolute maximum of 20V); the range for the VCC pin is 4.5 to 5.5V (5V typical). When there is power available in both pins, the VIN pin has priority and will be selected automatically to power up the LCD module and the backlight; in cases where there is no VIN available, the VCC pin will power up the whole board. The I2C expander comes pre-configured to work with 5V levels, using the voltage available on the VCC pins, but can also be configured to use 3.3V levels when this voltage is selected in the VI2C jumper on the board - donwload the schematics below for more details).
Does anyone know where I can find information on the empty surface mount pads on the back of this board? Seems like I should be able to save some wiring if I can use those.
You are the BEST!!! Thank you. It was worth registering just to post this message to you. I hope to participate further. There are a LOT of bugs in the Arduino sketches (Projects 1-23). Thanks again.
Working OK with Picaxe 20x2 but uses pins I would like to have free for i2c. So, I am getting bigger picaxe to go with it. Used 2 rectifier diodes in series for the voltage drop to 4.2v on the backlight and two 1k ohm resisters in series for the contrast. Looks good.
Thanks loophole! I got the display working fine using this link that link that was mentioned, http://arduino.cc/en/Tutorial/LiquidCrystal, but it was dim since the backlight was not working. After reading loophole"s comment and looking at datafile I applied 4.2V pin 15 and grounded pin 16, and all was GREAT!
How bright is this? I would like to leave it on in the dark but not have it too bright such that it looks like a light source. I"m considering getting this vs. the standard black on green since it looks nicer but hoping its not too bright in the night.
The post that KHartley posted with regards to all the pin connections and using an Aduino mini pro, who then also got a reply from member 468163, that the code and everything worked.
I am using the exact components and have followed the exact pin configurations for the past 2 weeks, connecting then reconnecting, I have also tried different FTDI cables for uploading onto the Arduino pro mini. BUT have had no success, PLEASE help me as it is a basic issue I am sure but cannot find the solution, My 16*2 LCD lights up and also when I upload a program the arduino page reads that it has successfully uploaded (Done Uploading).
I have seen that the other alternative or different way of setting up the circuit is by using a resistor instead of the 10K potentiometer that I am using.
Hey. looking to find a good mounting solution for this onto a project box. Any suggested DIY projects or prefab bezel solutions for a professional look?
We"ve had customers order face plates through Ponoko for these LCDs and be pretty happy with it. Check around on the comments on other products and on the forum. You"ll probably find a lot of different examples of mounting solutions.
can this run in 8bit mode? I"m trying so hard to just wire up the 8 data lines and manually send the bits required for certain symbols. But it"s either stuck in 4bit mode, or I"m completely lost. My program is simple and I KNOW that it is sending the 1"s and 0"s down the appropriate lines but I can"t get a response at all. And I can succesfully apply the example code for liquid crystal. In class we just banged some bits into those old lcd"s and got the expected response... Is this one more advanced or something? Thanks, I really appreciate any help.
No matter what line I set the cursor at using lcd.setCursor(0,0), or lcd.setCursor(0,1), it will print everything on line 0. I"ve used the same LCD, different size before and never had this issue.
You should make the LCD"s connection pins on the bottom, like on the RGB backlit LCD"s (https://www.sparkfun.com/products/10862). I like standing them straight up and down on breadboards. If I tried that with this one, it would be upside down.
I"m having a problem with this lcd, I can"d print custom caracters, I tried the code that this site http://icontexto.com/charactercreator/ gives you when you create a custom char, tried some other examples, but nothing, I always get just two vertical bars on the second and fourth columns.
I love this little LCD! It works great. However, I"m having a wicked hard time finding hardware (i.e. self-clinching PEM stud) that I can use to mount this. The 2.5mm mounting holes are pretty small. I"m trying hard not to use glues.
I"m having problems with my contrast - it"s always either too high (washed out characters) or too low (can"t see the character) on separate spaces at the same time. No matter how I adjust it, each character seems to require a different contrast level. Help, please?
I"m also having problems with contrast; I"m using a 10k pot on the contrast pin, and it takes tiny adjustments to make it work. After a minute or so running, the contrast starts to flicker, and I can"t seem to get it stable.
I"m also having trouble with LCD. I hooked up at 10kOhm pot, but when I upload the code it just gives me random pixels and characters. Is my Atmega on my Arduino Uno shot?
Like others have said, works well with liquidcrystal library and I also like to pwm the backlight with a fet on the low side. Looks really cool to have it fade out to 1 or 2% duty cycle standby mode when there has been no button presses/input in a while and then fade back in when you press a button.
Also no external resistor is needed for the backlight; just like almost all other 5v character LCDs this one has a series resistor right on the board. Mine is 130 ohms.
Works Great! Used with the Arduino and LiquidCrystal. Very clear and easy to read. I originally was setting contrast with a PWM pin to see how it worked(AKA I forgot to buy a trimpot), but it made the screen "pulse". Switched to a potentiometer I scrounged and that worked much better. Ive got the backlight hooked to +5 and its been working fine so far.
I was able to achieve much better contrast by applying a slightly negative voltage on the Vo pin (3). Minus 200 mV did the trick. I seem to remember that LCD"s used to have a negative output for just this reason. I don"t know what the rating of this pin is, so proceed with caution.
3) If you hook it to an Arduino, powering the LED backlight from a digital I/O pin will only source 40mA max. (PIC micros are even less), any more and you are overloading your output. Tie pin K (or 16) to ground, and A (or 15) will be the high side. If you design for 40mA, calculate the current limiting resistor to put between the I/O pin and pin A (or 15) of the LED backlight as follows: 5V-4.2V=0.8V and 0.8V/0.040A=20ohms however, be sure to measure the voltage across your current limiting resistor and calculate the actual current flowing to the LED just in case... don"t overload your Arduino I/O!
4) If you want to really drive it properly, you need more POWER! So grab an NPN transistor such as a 2N4401 or 2N2222 or 2N3904, and amplify your I/O. Hook a 220 to 330 ohm resistor between your I/O and the base of the NPN, hook the emitter of the NPN to ground, and the collector to the K pin (or 16) of the LED backlight. Hook a 5 to 10 ohm 1/4W resistor between the A pin (or 15) of the LED backlight and the 5V rail (make sure your 5V regulator can handle the extra 120-160mA of current you are going to be consuming)
what is the reason for the 5-10ohm resistor between the anode and the 5v? Someone mentioned that there is already a 130ohm resistor on the board in series with the backlight LED, so i can"t find a reason for it being there.
Thanks to the guy who first pointed that for that bcklight to work one needs pin 15 on +4.2V and pin 16 on ground. Without that I was getting a pretty dim job.
I made it work by using the same schematic featured in the LiquidCrystal Arduino library page, except LCD pin 6 is hooked to a digital PWM instead of a potentiometer for controlling contrast.
Pretty cool little LCD. I had some problems initially with the 4bit LCD library, but after finding that the standard LiquidCrystal library supports 4-bit data lines it worked great.
The one thing that threw me off was that the standard (not extended) datasheet mentions that the backlight (BKL) can be driven by pins 1,2 or 15,16 -- however I found that I needed to apply 4.2v to pins 15,16 before the backlight would work. Easy fix, just misleading on the datasheet.
I"m very impressed. I followed the connections from the data sheet and set them up the same way the LiquidCrystal "Hello World" example sketch calls for, and the display worked perfectly with my Arduino Duemilanove. It does take some playing with the contrast potentiometer, but I quickly found the perfect setting. The display is sharp, clear, and cool white letters on a black background.
Ordered mine a week ago and finally got around to playing with it. I used the included LiquidCrystal.h for Arduino to run this thing. Very easy to use once you get it up and running. To get the contrast working I used a 3.3Kohm resistor going to ground, looks amazing. Not quite as bright as picture but I think I"m close. 2.2Kohm is too washed out and 6.8 Kohm nothing shows up. I can"t believe how much easier this is compared to the 68HC12. Uhhh, I"m going to have nightmares for the rest of my life.
Hey I"m thinking of buying one, but I"d like to know. How bright is it, I"m thinking of using it on a buggy to show fuel, tack, and speed. So it will be vibrating around in bright sunlight. My question is, will it be legible?
Have you wired in the backlight? That tutorial doesn"t include wiring pins 15 and 16 on the lcd. I have hooked the backlight up to a pwm output so that I can turn it on and off via sketch.
I am also ahving this same problem. The LCD was great and easy to set up, but the brightness is really really poor. I installed a pot and all, but no dice.
Has anyone got this working with the LiquidCrystal or LCD4bit library? I am having quite a bit of trouble getting it to work reliably and am at the point where I am going to try and code my own library for it.
I"m also having heaps of trouble. I can sometimes get it to display text, maybe once out of every 30 attempts. And IF it decides to display anything it ends up garbling the message and locking up, not displaying the other strings in the sequence. Is this the LCD, my Arduino or the library? I tried using LCD4bit and a modified LiquidCrystal and they all yield the same, frustrating results.
Late reply, but I have trouble with this if I forget to add decoupling capacitors on the V+ line. Especialy using multiple serial to parallel converters at high data rates.
Great little lcd, for basic output, debugging etc. Very easy to interface, and looks very slick! If you need a basic no frills LCD, this is a good buy.
In this tutorial, you’ll learn how to interface ESP32 with an LCD display 16×2 without I2C. It can be useful in some projects, however, it’s not very common, due to the GPIO pins it does consume. But it’s going to be a good starting point if you’re new to Alphanumeric LCDs in general or just want to use the generic Arduino LiquidCrystal display library.
You can either get the complete course kit for this series of tutorials using the link down below. Or just refer to the table for the exact components to be used in practical LABs for only this specific tutorial.
Alphanumeric LCD 16×2 display units are the most common and easiest solutions to get some data out of your microcontroller to the world to visually see. It’s a very cheap, easy to use, and reliable option to display strings of text/numbers to your system’s users.
The only downside to using the bare 16×2 LCD display is that it requires 6 dedicated GPIO pins of your microcontroller. In the case of our ESP32, it can be really annoying to lose 6 GPIO pins for adding only 1 LCD module to the project. However, in some projects, it can be a good option in case you don’t need the extra GPIO pins anyway.
The second most commonly preferred option is by using the I2C module with your LCD. This will reduce the GPIO pins requirement down to only 2 pins (the I2C pins SDA & SCL). Not only that, actually the 2 pins of that I2C bus can still access so many other I2C devices on the exact same bus.
You can end up having maybe 5 LCDs connected to your microcontroller using only 2 pins If you’re using that I2C module. But it’s the topic of the next tutorial. For this tutorial, we’ll be doing bare LCD interfacing in a classic way without an I2C IO expansion module.
This is the pinout for a typical LCD 16×2 display unit. It’s got 8 data lines (you can use only 4 of them or all of the 8). And remember that it needs to be powered from a +5v source despite the fact that our ESP32 is a 3.3v microcontroller device. This requirement is only for the power supply pins, not the data lines.
There are two ways to interface the LCD diver (controller) IC. You can use the full bus width (8-Bits) for data or alternatively you can use a 4-Bit interface for a reduced pin count needed to control the LCD. Specifically low pin count MCUs need to operate in the 4-Bit mode. And it’s the case for our ESP32 which has limited resources in terms of GPIO pin count.
The differences between 8-Bit mode and 4-Bit mode are that in the 8-Bit mode you’re operating the LCD at the full speed. While in 4-Bit mode, you send each data byte or command in two consecutive cycles instead of one. The other difference is the initialization routine steps. This is detailed in the full LCD article linked below.
If you’re interested in learning more about the LCD display, how it works, how does the LCD driver IC work (the circular black thing on the back), its internal registers, and more. Then, you should check outthis tutorial linked down below.
In that tutorial, we’ll be scrolling through the LCD driver datasheet, learning how it works, how to write a driver firmware library for it, and build our own library in Embedded-C with PIC microcontrollers from scratch and test it out in a couple of LABs.
In this section, I’ll give you a brief description of the LiquidCrystal library that we’ll be using in this tutorial. And it’s basic API functions to initialize and write some text on any LCD. We’ll be using the generic LiquidCrystal library (not the I2C version) which is similar to any other Arduino LCD example code you’ve seen online.
The Arduino LiquidCrystal library gives you all the functionalities that you’d need from an LCD driver and it’s very easy to use in your projects. Here are the exact steps you need to follow in order to initialize and write to an LCD in your project code (in Arduino IDE).
Step2– Create an LCD object. In which you’ll define the GPIO pins to be used for the various LCD signals (6 pins). This is done in code as shown below
Step3– Now, you need to initialize the LCD in the Setup function, and it’s better to clear the display to make sure there are no random characters on the visible display. In this step, you also define the number of rows and columns for your display. There are many versions of this LCD display not only 16×2, there are 16×4, 20×4, and maybe others.
Step4– Now, our LCD is properly initialized and ready for displaying any data or executing any commands. To write something on the LCD you can use the LCD_object.print() function. As you can see in the example code down below
We use the LCD_object.setCursor() function to set the cursor position, so the next LCD write operation occurs exactly at that location. And that’s it! Here is how it looks like in real-life testing.
The diagram down below shows you the connection between ESP32 and the LCD 16×2 display (in 4-Bit data mode). Note that the LCD requires a +5v supply and the ESP32 is a 3.3v board, however, it’s got the USB Vbus available on the Vin pin. So, we’ll be using the Vin pin as a +5v source (it’s measured to be 4.7v but it’s sufficient indeed).
The 10k potentiometer here is used to control the Contrast of the display. Try adjusting the contrast level by turning this pot right and left for best visibility depending on the ambient light condition in the room you’re testing in.
*Affiliate Disclosure: When you click on links in this section and make a purchase, this can result in this site earning a commission. Affiliate programs and affiliations include, but are not limited to, the eBay Partner Network (EPN) and Amazon.com, Banggood.com. This may be one of the ways to support this free platform while getting your regular electronic parts orders as usual at no extra cost to you.
The code example down below does the following: We start with including the LiquidCrystal library, then create an LCD object and initialize it. Then, we’ll write to the home position “Hello World!”, and move the cursor to the middle of the 2nd row and write “GG izi”. And nothing to be done in the main loop() function.
Choose the board, COM port, hold down the BOOT button, click upload and keep your finger on the BOOT button pressed. When the Arduino IDE starts sending the code, you can release the button and wait for the flashing process to be completed. Now, the ESP32 is flashed with the new firmware.
The LCD display’s controller (Hitachi HD44780) supports up to 8 custom characters that you can create and store on the LCD itself. Then you can send the Index of each custom character to be displayed later. Maybe 8 custom characters are not enough for your project, but it’s one little extra feature that you can occasionally use.
Those are some of the other functions available in the LiquidCrystal library that you may need to use in other projects. And check out the Arduino official reference for this library.
You can also check the ESP32 Course Home Page