Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Lab Activity 3
1. 1
EXPT#3. Digital Out - 16x2 Liquid Crystal Display
I.Learning Objectives:
After successfully completing this lab, students will be able to:
1. To interface a 16×2 LCD with the Arduino
2. To use and implement the basic controls of LCD with the Arduino.
3. To create a demonstration project that will show off most of the functions available in the
LiquidCrystal.h library.
4. To develop a counter that can efficiently count and display in LCD.
Pin configurationof the LCD(16X2)
9. 9
lcd.rightToLeft()
Thisfunctionsetsthe directionthattextisprintedtothe screen.The defaultmode isfromlefttoright
usingthe commandlcd.leftToRight(),butyoumayfindsome caseswhere it’suseful tooutputtextinthe
reverse direction:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5, 4, 3, 2);
voidsetup() {
lcd.begin(16,2);
lcd.setCursor(12,0);
lcd.rightToLeft();
lcd.print("hello,world!");
}
voidloop() {
}
Output
lcd.createChar()
Thiscommandallowsyouto create your owncustomcharacters. Each character of a 16×2 LCD has a 5
pixel widthandan8 pixel height.Upto8 differentcustomcharacterscan be definedinasingle
program.To designyourowncharacters,you’ll needtomake abinarymatrix of your custom character
froman LCD character generatorormap it yourself.Thiscode createsadegree symbol (°):
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5, 4, 3, 2);
byte customChar[8] = {
0b00110,
0b01001,
0b01001,
0b00110,
0b00000,
0b00000,
0b00000,
0b00000
10. 10
};
voidsetup()
{
lcd.createChar(0,customChar);
lcd.begin(16,2);
lcd.write((uint8_t)0);
}
voidloop() {
}
Output
EXERCISE:
LCD Temperature Display
Thisprojectis a simple demonstrationof usinganLCD to present useful informationtothe user—in this
case, the temperature from an analog temperature sensor. You will add a button to switch between
displaying the temperature in Celsius or Fahrenheit.Also, the maximumand minimum temperature will
be displayed on the second row.
Parts Required
16x2 Backlit LCD
Current Limiting Resistor (Backlight)
Current Limiting Resistor (Contrast)
Pushbutton
Analogue Temperature Sensor(Make sure that the temperature sensor only outputs positive values.)
LM35DT temperature sensor, which has a range from 0ºC to 100ºC. You can use any analogue
temperature sensor. The LM35 is rated from -55ºC to +150ºC.
NOTE: Whenyourun the code the currenttemperature will be displayedonthe top row of the LCD. The
bottomrowwill displaythe maximumandminimumtemperaturesrecordedsincethe Arduinowas turned
on or the program was reset. By pressing the button, you can change the temperature scale between
Celsius and Fahrenheit
Output