Line 38: Line 38:
 
=Demo=
 
=Demo=
 
=References=
 
=References=
 +
* [https://www.arduino.cc/en/Tutorial/LiquidCrystalDisplay LiquidCrystalDisplay tutorial on Arduino Website]

Revision as of 17:01, 8 June 2016

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

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

Demo

References