Character Liquid crystal displays are very handy and extremely simple to use. In this tutorial let us hook up 16x1, 16x2, 20x4 displays and test them with Explore M3. We will be using the LiquidCrystal Arduino library to accomplish this.

Hook up

There are various modes in which these displays can be connected to Explore M3 as shown below. It is combination of using 8 bit or 4 bits as database and using or not using the RW line on the display.

  • LiquidCrystal(rs, enable, d4, d5, d6, d7)
  • LiquidCrystal(rs, rw, enable, d4, d5, d6, d7)
  • LiquidCrystal(rs, enable, d0, d1, d2, d3, d4, d5, d6, d7)
  • LiquidCrystal(rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7)

So lets use the first mode which needs the least of the pins. The potentiometer is used to set the display contrast and resistor limits current to the LCD back-light. Explore m3 lcd.jpg

Code

  1. // include the library code:
  2. #include <LiquidCrystal.h>
  3.  
  4. // initialize the library with the numbers of the interface pins
  5. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  6.  
  7. void setup() {
  8. // set up the LCD's number of rows and columns:
  9. lcd.begin(16, 2);
  10. // Print a message to the LCD.
  11. lcd.print("hello, world!");
  12. }
  13.  
  14. void loop() {
  15. // set the cursor to column 0, line 1
  16. // (note: line 1 is the second row, since counting begins with 0):
  17. lcd.setCursor(0, 1);
  18. // print the number of seconds since reset:
  19. lcd.print(millis()/1000);
  20. }

20 x 4 Character LCD

  1. //Demonstrates use of 20x4 character display on Explore M3
  2.  
  3. #include <LiquidCrystal.h>
  4. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  5.  
  6. void setup() {
  7. lcd.begin(20,4); // 20 Characters on 4 lines
  8. }
  9.  
  10. void loop() {
  11. lcd.setCursor(0, 0);
  12. lcd.print("Explore M3");
  13. lcd.setCursor(0, 1);
  14. lcd.print("Character LCD");
  15. lcd.setCursor(0, 2);
  16. lcd.print("4 lines");
  17. lcd.setCursor(0, 3);
  18. lcd.print("20 Characters ;)");
  19. }

Demo

The same hookup can be used to interface 16x1, 16x4 and 20x4 displays. The only things that will change is

  1. lcd.begin(16, 2); //for 16x2 display
  2. lcd.begin(16, 1); //for 16x1 display
  3. lcd.begin(20, 4); //for 20x4 display
  4.  
  5. lcd.setCursor(0, 1); //can be used to set the cursor, according to the display size.

16 x 2 Display

16X1 M3.JPG

20 x 4 Display

20x4 m3.JPG

References

Going further you may want to explore bare metal way to interface displays with Explore M3. Mind you, that will be more in-depth stuff in terms display as well as the controller.

Explore M3 Introduction

Explore M3 is a feature rich ARM Cortex M3 development board. It can help you prototype ideas faster with Arduino/mbed and take them be beyond with bare metal programming, RTOS support and lower power...

Arduino Setup for Explore M3

In this tutorial we will look at the basic setups of setting up the ExploreM3 on Arduino and installing DFU and Vcom drivers on Windows, Linux and MAC. Finally we will flash a simple led-blink example...

Led Blink with Explore M3

Blinking an LED is fun for a newbie, a setup test for a Embedded Developer and for this tutorial it getting started with Explore M3 and answering some basic questions like, where did it come from...

Explore M3 Arduino Libraries

Arduino libraries need no introduction. There are numerous devices and peripherals that work with Arduino. This page lists all the libraries that have been tested or ported to Explore M3. ...