SlideShare une entreprise Scribd logo
1  sur  10
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)
2
Schematic Diagram
LCD Display
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5, 4, 3, 2);
voidsetup() {
lcd.begin(16,2);
lcd.print("hello,world!");
}
voidloop() {
}
Output
LCD DisplayOption
lcd.begin()
Thisfunctionsetsthe dimensionsof the LCD.It needstobe placedbefore anyotherLiquidCrystal
functioninthe voidsetup() sectionof the program.The numberof rows andcolumnsare specifiedas
3
lcd.begin(columns,rows).Fora16×2 LCD, you woulduse lcd.begin(16,2),andfor a 20×4 LCD you would
use lcd.begin(20,4).
lcd.clear()
Thisfunctionclearsanytextor data alreadydisplayedonthe LCD.If you use lcd.clear() withlcd.print()
and the delay() functioninthe voidloop() section,youcanmake a simple blinkingtextprogram:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5, 4, 3, 2);
voidsetup() {
lcd.begin(16,2);
}
voidloop() {
lcd.print("hello,world!");
delay(500);
lcd.clear();
delay(500);
}
Output
lcd.home()
Thisfunctionplacesthe cursorin the upperlefthandcornerof the screen,andprintsany subsequent
textfromthat position.Forexample,thiscode replacesthe firstthree lettersof “helloworld!”withX’s:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5, 4, 3, 2);
voidsetup() {
lcd.begin(16,2);
lcd.print("hello,world!");
}
voidloop() {
4
lcd.home();
lcd.print("XXX");
}
Output
lcd.setCursor()
Similar,butmore useful thanlcd.home() islcd.setCursor().This functionplacesthe cursor(andany
printedtext) atanypositiononthe screen.Itcan be usedinthe voidsetup() orvoidloop() sectionof
your program.
The cursor positionisdefinedwithlcd.setCursor(column,row).The columnandrow coordinatesstart
fromzero (0-15 and 0-1 respectively).Forexample,usinglcd.setCursor(2,1) inthe voidsetup() section
of the “hello,world!”programabove prints“hello,world!”tothe lowerline andshiftsittothe righttwo
spaces:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5, 4, 3, 2);
voidsetup() {
lcd.begin(16,2);
lcd.setCursor(2,1);
lcd.print("hello,world!");
}
voidloop() {
}
Output
lcd.write()
You can use thisfunctiontowrite differenttypesof datato the LCD, for example the readingfroma
temperature sensor,orthe coordinatesfromaGPS module.Youcanalso use itto printcustom
5
characters that youcreate yourself (more onthisbelow).Use lcd.write() inthe voidsetup() orvoid
loop() sectionof yourprogram.
lcd.print()
Thisfunctionisusedto printtextto the LCD. It can be usedinthe voidsetup() sectionorthe voidloop()
sectionof the program.
To printlettersandwords,place quotationmarks(”“) around the text.Forexample,toprinthello,
world!,use lcd.print(“hello,world!”).
To printnumbers,noquotationmarksare necessary.Forexample,toprint123456789, use
lcd.print(123456789).
lcd.print() canprintnumbersin decimal, binary,hexadecimal,andoctal bases.Forexample:
lcd.print(100,DEC) prints“100”;
lcd.print(100,BIN) prints“1100100”
lcd.print(100,HEX) prints“64”
lcd.print(100,OCT) prints“144”
Output
lcd.Cursor()
Thisfunctioncreatesa visible cursor.The cursorisa horizontal line placedbelow the nextcharacterto
be printedtothe LCD.
The functionlcd.noCursor() turnsthe cursoroff.lcd.cursor() andlcd.noCursor()canbe usedtogetherin
the voidloop() sectiontomake ablinkingcursorsimilartowhatyousee inmany textinputfields:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5, 4, 3, 2);
voidsetup() {
lcd.begin(16,2);
lcd.print("hello,world!");
}
voidloop() {
6
lcd.cursor();
delay(500);
lcd.noCursor();
delay(500);
}
Output
Thisplacesa blinkingcursorafterthe exclamationpointin“hello,world!”
Cursorscan be placedanywhere onthe screenwiththe lcd.setCursor()function.Thiscode placesa
blinkingcursordirectlybelowthe exclamationpointin“hello,world!”:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5, 4, 3, 2);
voidsetup() {
lcd.begin(16,2);
lcd.print("hello,world!");
}
voidloop() {
lcd.setCursor(12,1);
lcd.cursor();
delay(500);
lcd.setCursor(12,1);
lcd.noCursor();
delay(500);
}
Output
lcd.blink()
Thisfunctioncreatesa blockstyle cursorthat blinksonandoff at approximately500millisecondsper
cycle.Use itin the voidloop() section.The functionlcd.noBlink() disablesthe blinkingblockcursor.
7
lcd.display()
Thisfunctionturnson anytextor cursors that have beenprintedtothe LCD screen.The function
lcd.noDisplay() turnsoff anytextorcursorsprintedto the LCD, withoutclearingitfromthe LCD’s
memory.
These twofunctions canbe usedtogetherinthe voidloop() sectiontocreate ablinkingtexteffect.This
code will make the “hello,world!”textblinkonandoff:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5, 4, 3, 2);
voidsetup() {
lcd.begin(16,2);
lcd.print("hello,world!");
}
voidloop() {
lcd.display();
delay(500);
lcd.noDisplay();
delay(500);
}
Output
lcd.scrollDisplayLeft()
Thisfunctiontakesanythingprintedtothe LCDand movesitto the left.Itshouldbe usedinthe void
loop() sectionwithadelaycommandfollowingit.The functionwill move the text40spacesto the left
before itloopsbackto the firstcharacter. Thiscode movesthe “hello,world!”texttothe left,ata rate
of one secondpercharacter:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5, 4, 3, 2);
voidsetup() {
lcd.begin(16,2);
lcd.print("hello,world!");
}
8
voidloop() {
lcd.scrollDisplayLeft();
delay(1000);
}
Output
lcd.scrollDisplayRight()
Thisfunctionbehaveslikelcd.scrollDisplayLeft(),butmovesthe texttothe right.
lcd.autoscroll()
Thisfunctiontakesa stringof textand scrollsitfromright to leftinincrementsof the charactercountof
the string.For example,if youhave astringof textthat is3 characters long,itwill shiftthe text3spaces
to the leftwitheachstep:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5, 4, 3, 2);
voidsetup() {
lcd.begin(16,2);
}
voidloop() {
lcd.setCursor(0,0);
lcd.autoscroll();
lcd.print("ABC");
delay(500);
}
Output
lcd.noAutoscroll()
lcd.noAutoscroll() turnsthe lcd.autoscroll() functionoff.Use thisfunctionbefore orafterlcd.autoscroll()
inthe voidloop() sectiontocreate sequencesof scrollingtextoranimations.
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
};
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

Contenu connexe

Similaire à Lab Activity 3

Advance Computer Architecture
Advance Computer ArchitectureAdvance Computer Architecture
Advance Computer ArchitectureVrushali Lanjewar
 
Snake Game on FPGA in Verilog
Snake Game on FPGA in VerilogSnake Game on FPGA in Verilog
Snake Game on FPGA in VerilogKrishnajith S S
 
Lcd tutorial for interfacing with microcontrollers basics of alphanumeric lc...
Lcd tutorial for interfacing with microcontrollers  basics of alphanumeric lc...Lcd tutorial for interfacing with microcontrollers  basics of alphanumeric lc...
Lcd tutorial for interfacing with microcontrollers basics of alphanumeric lc...mdkousik
 
Moving message display
Moving message displayMoving message display
Moving message displayviraj1989
 
SIMPLE Frequency METER using AT89c51
SIMPLE Frequency METER using AT89c51 SIMPLE Frequency METER using AT89c51
SIMPLE Frequency METER using AT89c51 aroosa khan
 
Copy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with QtCopy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with Qtaccount inactive
 
Open Standards for ADAS: Andrew Richards, Codeplay, at AutoSens 2016
Open Standards for ADAS: Andrew Richards, Codeplay, at AutoSens 2016Open Standards for ADAS: Andrew Richards, Codeplay, at AutoSens 2016
Open Standards for ADAS: Andrew Richards, Codeplay, at AutoSens 2016Andrew Richards
 
Lcd module interface with xilinx software using verilog
Lcd module interface with xilinx software using verilogLcd module interface with xilinx software using verilog
Lcd module interface with xilinx software using verilogsumedh23
 
Lcd interfaing using 8051 and assambly language programming
Lcd interfaing using 8051 and assambly language programmingLcd interfaing using 8051 and assambly language programming
Lcd interfaing using 8051 and assambly language programmingVikas Dongre
 
COMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORTCOMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORTvineet raj
 
2022-BEKM 3453 - LCD and keypad.pdf
2022-BEKM 3453 - LCD and keypad.pdf2022-BEKM 3453 - LCD and keypad.pdf
2022-BEKM 3453 - LCD and keypad.pdfVNEX
 
AutoCAD Productivity Hacks for Engineers, Architects, Designers, and Draftsme...
AutoCAD Productivity Hacks for Engineers, Architects, Designers, and Draftsme...AutoCAD Productivity Hacks for Engineers, Architects, Designers, and Draftsme...
AutoCAD Productivity Hacks for Engineers, Architects, Designers, and Draftsme...Ndianabasi Udonkang
 

Similaire à Lab Activity 3 (20)

Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Advance Computer Architecture
Advance Computer ArchitectureAdvance Computer Architecture
Advance Computer Architecture
 
Basic standard calculator
Basic standard calculatorBasic standard calculator
Basic standard calculator
 
Graphics in C++
Graphics in C++Graphics in C++
Graphics in C++
 
_LCD display-mbed.pdf
_LCD display-mbed.pdf_LCD display-mbed.pdf
_LCD display-mbed.pdf
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
Snake Game on FPGA in Verilog
Snake Game on FPGA in VerilogSnake Game on FPGA in Verilog
Snake Game on FPGA in Verilog
 
Howto curses
Howto cursesHowto curses
Howto curses
 
Est 8 2 nd
Est 8 2 ndEst 8 2 nd
Est 8 2 nd
 
Lcd tutorial for interfacing with microcontrollers basics of alphanumeric lc...
Lcd tutorial for interfacing with microcontrollers  basics of alphanumeric lc...Lcd tutorial for interfacing with microcontrollers  basics of alphanumeric lc...
Lcd tutorial for interfacing with microcontrollers basics of alphanumeric lc...
 
Moving message display
Moving message displayMoving message display
Moving message display
 
SIMPLE Frequency METER using AT89c51
SIMPLE Frequency METER using AT89c51 SIMPLE Frequency METER using AT89c51
SIMPLE Frequency METER using AT89c51
 
Copy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with QtCopy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with Qt
 
Open Standards for ADAS: Andrew Richards, Codeplay, at AutoSens 2016
Open Standards for ADAS: Andrew Richards, Codeplay, at AutoSens 2016Open Standards for ADAS: Andrew Richards, Codeplay, at AutoSens 2016
Open Standards for ADAS: Andrew Richards, Codeplay, at AutoSens 2016
 
Arduino: Arduino lcd
Arduino: Arduino lcdArduino: Arduino lcd
Arduino: Arduino lcd
 
Lcd module interface with xilinx software using verilog
Lcd module interface with xilinx software using verilogLcd module interface with xilinx software using verilog
Lcd module interface with xilinx software using verilog
 
Lcd interfaing using 8051 and assambly language programming
Lcd interfaing using 8051 and assambly language programmingLcd interfaing using 8051 and assambly language programming
Lcd interfaing using 8051 and assambly language programming
 
COMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORTCOMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORT
 
2022-BEKM 3453 - LCD and keypad.pdf
2022-BEKM 3453 - LCD and keypad.pdf2022-BEKM 3453 - LCD and keypad.pdf
2022-BEKM 3453 - LCD and keypad.pdf
 
AutoCAD Productivity Hacks for Engineers, Architects, Designers, and Draftsme...
AutoCAD Productivity Hacks for Engineers, Architects, Designers, and Draftsme...AutoCAD Productivity Hacks for Engineers, Architects, Designers, and Draftsme...
AutoCAD Productivity Hacks for Engineers, Architects, Designers, and Draftsme...
 

Plus de Dwight Sabio

Human Rights Observatory Description
Human Rights Observatory DescriptionHuman Rights Observatory Description
Human Rights Observatory DescriptionDwight Sabio
 
RIGHTS-BASED SUSTAINABLE DEVELOPMENT GOALS MONITOR
RIGHTS-BASED SUSTAINABLE DEVELOPMENT GOALS MONITORRIGHTS-BASED SUSTAINABLE DEVELOPMENT GOALS MONITOR
RIGHTS-BASED SUSTAINABLE DEVELOPMENT GOALS MONITORDwight Sabio
 
Report on Girl Children: A Rapid Assessment of their Situation
Report on Girl Children: A Rapid Assessment of their SituationReport on Girl Children: A Rapid Assessment of their Situation
Report on Girl Children: A Rapid Assessment of their SituationDwight Sabio
 
Gender ombud report 2016 final
Gender ombud report 2016 finalGender ombud report 2016 final
Gender ombud report 2016 finalDwight Sabio
 
Strengthening legal referral mechanisms on cases of gender
Strengthening legal referral mechanisms on cases of genderStrengthening legal referral mechanisms on cases of gender
Strengthening legal referral mechanisms on cases of genderDwight Sabio
 
CPU scheduling ppt file
CPU scheduling ppt fileCPU scheduling ppt file
CPU scheduling ppt fileDwight Sabio
 
OperatingSystemChp3
OperatingSystemChp3OperatingSystemChp3
OperatingSystemChp3Dwight Sabio
 
Programming Problem 3
Programming Problem 3Programming Problem 3
Programming Problem 3Dwight Sabio
 
Programming Problem 2
Programming Problem 2Programming Problem 2
Programming Problem 2Dwight Sabio
 
Midterm Project Specification
Midterm Project Specification Midterm Project Specification
Midterm Project Specification Dwight Sabio
 
Game Design Document
Game Design DocumentGame Design Document
Game Design DocumentDwight Sabio
 
ProgrammingProblem
ProgrammingProblemProgrammingProblem
ProgrammingProblemDwight Sabio
 

Plus de Dwight Sabio (20)

Human Rights Observatory Description
Human Rights Observatory DescriptionHuman Rights Observatory Description
Human Rights Observatory Description
 
RIGHTS-BASED SUSTAINABLE DEVELOPMENT GOALS MONITOR
RIGHTS-BASED SUSTAINABLE DEVELOPMENT GOALS MONITORRIGHTS-BASED SUSTAINABLE DEVELOPMENT GOALS MONITOR
RIGHTS-BASED SUSTAINABLE DEVELOPMENT GOALS MONITOR
 
Report on Girl Children: A Rapid Assessment of their Situation
Report on Girl Children: A Rapid Assessment of their SituationReport on Girl Children: A Rapid Assessment of their Situation
Report on Girl Children: A Rapid Assessment of their Situation
 
Gender ombud report 2016 final
Gender ombud report 2016 finalGender ombud report 2016 final
Gender ombud report 2016 final
 
Strengthening legal referral mechanisms on cases of gender
Strengthening legal referral mechanisms on cases of genderStrengthening legal referral mechanisms on cases of gender
Strengthening legal referral mechanisms on cases of gender
 
IP Report
IP ReportIP Report
IP Report
 
CPU scheduling ppt file
CPU scheduling ppt fileCPU scheduling ppt file
CPU scheduling ppt file
 
Ch3OperSys
Ch3OperSysCh3OperSys
Ch3OperSys
 
OperatingSystemChp3
OperatingSystemChp3OperatingSystemChp3
OperatingSystemChp3
 
ABC Supermarket
ABC SupermarketABC Supermarket
ABC Supermarket
 
Programming Problem 3
Programming Problem 3Programming Problem 3
Programming Problem 3
 
Lab Activity
Lab ActivityLab Activity
Lab Activity
 
Bluetooth
Bluetooth Bluetooth
Bluetooth
 
Programming Problem 2
Programming Problem 2Programming Problem 2
Programming Problem 2
 
Arduino e-book
Arduino e-bookArduino e-book
Arduino e-book
 
Midterm Project Specification
Midterm Project Specification Midterm Project Specification
Midterm Project Specification
 
Game Design Document
Game Design DocumentGame Design Document
Game Design Document
 
Class diagram
Class diagramClass diagram
Class diagram
 
Midterm Project
Midterm Project Midterm Project
Midterm Project
 
ProgrammingProblem
ProgrammingProblemProgrammingProblem
ProgrammingProblem
 

Dernier

SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 

Dernier (20)

SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
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)
  • 2. 2 Schematic Diagram LCD Display #include <LiquidCrystal.h> LiquidCrystal lcd(12,11,5, 4, 3, 2); voidsetup() { lcd.begin(16,2); lcd.print("hello,world!"); } voidloop() { } Output LCD DisplayOption lcd.begin() Thisfunctionsetsthe dimensionsof the LCD.It needstobe placedbefore anyotherLiquidCrystal functioninthe voidsetup() sectionof the program.The numberof rows andcolumnsare specifiedas
  • 3. 3 lcd.begin(columns,rows).Fora16×2 LCD, you woulduse lcd.begin(16,2),andfor a 20×4 LCD you would use lcd.begin(20,4). lcd.clear() Thisfunctionclearsanytextor data alreadydisplayedonthe LCD.If you use lcd.clear() withlcd.print() and the delay() functioninthe voidloop() section,youcanmake a simple blinkingtextprogram: #include <LiquidCrystal.h> LiquidCrystal lcd(12,11,5, 4, 3, 2); voidsetup() { lcd.begin(16,2); } voidloop() { lcd.print("hello,world!"); delay(500); lcd.clear(); delay(500); } Output lcd.home() Thisfunctionplacesthe cursorin the upperlefthandcornerof the screen,andprintsany subsequent textfromthat position.Forexample,thiscode replacesthe firstthree lettersof “helloworld!”withX’s: #include <LiquidCrystal.h> LiquidCrystal lcd(12,11,5, 4, 3, 2); voidsetup() { lcd.begin(16,2); lcd.print("hello,world!"); } voidloop() {
  • 4. 4 lcd.home(); lcd.print("XXX"); } Output lcd.setCursor() Similar,butmore useful thanlcd.home() islcd.setCursor().This functionplacesthe cursor(andany printedtext) atanypositiononthe screen.Itcan be usedinthe voidsetup() orvoidloop() sectionof your program. The cursor positionisdefinedwithlcd.setCursor(column,row).The columnandrow coordinatesstart fromzero (0-15 and 0-1 respectively).Forexample,usinglcd.setCursor(2,1) inthe voidsetup() section of the “hello,world!”programabove prints“hello,world!”tothe lowerline andshiftsittothe righttwo spaces: #include <LiquidCrystal.h> LiquidCrystal lcd(12,11,5, 4, 3, 2); voidsetup() { lcd.begin(16,2); lcd.setCursor(2,1); lcd.print("hello,world!"); } voidloop() { } Output lcd.write() You can use thisfunctiontowrite differenttypesof datato the LCD, for example the readingfroma temperature sensor,orthe coordinatesfromaGPS module.Youcanalso use itto printcustom
  • 5. 5 characters that youcreate yourself (more onthisbelow).Use lcd.write() inthe voidsetup() orvoid loop() sectionof yourprogram. lcd.print() Thisfunctionisusedto printtextto the LCD. It can be usedinthe voidsetup() sectionorthe voidloop() sectionof the program. To printlettersandwords,place quotationmarks(”“) around the text.Forexample,toprinthello, world!,use lcd.print(“hello,world!”). To printnumbers,noquotationmarksare necessary.Forexample,toprint123456789, use lcd.print(123456789). lcd.print() canprintnumbersin decimal, binary,hexadecimal,andoctal bases.Forexample: lcd.print(100,DEC) prints“100”; lcd.print(100,BIN) prints“1100100” lcd.print(100,HEX) prints“64” lcd.print(100,OCT) prints“144” Output lcd.Cursor() Thisfunctioncreatesa visible cursor.The cursorisa horizontal line placedbelow the nextcharacterto be printedtothe LCD. The functionlcd.noCursor() turnsthe cursoroff.lcd.cursor() andlcd.noCursor()canbe usedtogetherin the voidloop() sectiontomake ablinkingcursorsimilartowhatyousee inmany textinputfields: #include <LiquidCrystal.h> LiquidCrystal lcd(12,11,5, 4, 3, 2); voidsetup() { lcd.begin(16,2); lcd.print("hello,world!"); } voidloop() {
  • 6. 6 lcd.cursor(); delay(500); lcd.noCursor(); delay(500); } Output Thisplacesa blinkingcursorafterthe exclamationpointin“hello,world!” Cursorscan be placedanywhere onthe screenwiththe lcd.setCursor()function.Thiscode placesa blinkingcursordirectlybelowthe exclamationpointin“hello,world!”: #include <LiquidCrystal.h> LiquidCrystal lcd(12,11,5, 4, 3, 2); voidsetup() { lcd.begin(16,2); lcd.print("hello,world!"); } voidloop() { lcd.setCursor(12,1); lcd.cursor(); delay(500); lcd.setCursor(12,1); lcd.noCursor(); delay(500); } Output lcd.blink() Thisfunctioncreatesa blockstyle cursorthat blinksonandoff at approximately500millisecondsper cycle.Use itin the voidloop() section.The functionlcd.noBlink() disablesthe blinkingblockcursor.
  • 7. 7 lcd.display() Thisfunctionturnson anytextor cursors that have beenprintedtothe LCD screen.The function lcd.noDisplay() turnsoff anytextorcursorsprintedto the LCD, withoutclearingitfromthe LCD’s memory. These twofunctions canbe usedtogetherinthe voidloop() sectiontocreate ablinkingtexteffect.This code will make the “hello,world!”textblinkonandoff: #include <LiquidCrystal.h> LiquidCrystal lcd(12,11,5, 4, 3, 2); voidsetup() { lcd.begin(16,2); lcd.print("hello,world!"); } voidloop() { lcd.display(); delay(500); lcd.noDisplay(); delay(500); } Output lcd.scrollDisplayLeft() Thisfunctiontakesanythingprintedtothe LCDand movesitto the left.Itshouldbe usedinthe void loop() sectionwithadelaycommandfollowingit.The functionwill move the text40spacesto the left before itloopsbackto the firstcharacter. Thiscode movesthe “hello,world!”texttothe left,ata rate of one secondpercharacter: #include <LiquidCrystal.h> LiquidCrystal lcd(12,11,5, 4, 3, 2); voidsetup() { lcd.begin(16,2); lcd.print("hello,world!"); }
  • 8. 8 voidloop() { lcd.scrollDisplayLeft(); delay(1000); } Output lcd.scrollDisplayRight() Thisfunctionbehaveslikelcd.scrollDisplayLeft(),butmovesthe texttothe right. lcd.autoscroll() Thisfunctiontakesa stringof textand scrollsitfromright to leftinincrementsof the charactercountof the string.For example,if youhave astringof textthat is3 characters long,itwill shiftthe text3spaces to the leftwitheachstep: #include <LiquidCrystal.h> LiquidCrystal lcd(12,11,5, 4, 3, 2); voidsetup() { lcd.begin(16,2); } voidloop() { lcd.setCursor(0,0); lcd.autoscroll(); lcd.print("ABC"); delay(500); } Output lcd.noAutoscroll() lcd.noAutoscroll() turnsthe lcd.autoscroll() functionoff.Use thisfunctionbefore orafterlcd.autoscroll() inthe voidloop() sectiontocreate sequencesof scrollingtextoranimations.
  • 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