SlideShare a Scribd company logo
1 of 21
Download to read offline
LCD display-MBED
Dr.M.Vidhyalakshmi
SRMIST/RMP
LCD DISPLAY
PC1602F
HD44780 communication lines
Using modular coding to interface the LCD display Our LCD.h header
/* Program Example 8.1: LCD.h header file
*/
#ifndef LCD_H
#define LCD_H
#include "mbed.h"
void toggle_enable(void); //function to toggle/pulse the enable bit void
LCD_init(void); //function to initialise the LCD void
display_to_LCD(char value); //function to display characters
#endif
Initialising the display
wait a short period (approximately 20 ms), then set the RS and E lines to zero and
then send a number of configuration messages to set up the LCD.
We then need to send configuration data to the
• Function Mode register
• Display Mode register
• Clear Display register
In order to initialise the display.
Initialising the display
Function Mode
To set the LCD function mode, the RS, R/|W and DB0-7 bits should be set as
shown below. Remember in 4-bit mode, data bus values are sent as two
nibbles.
Display Mode
The Display Mode control register must also be set up during initialisation. Here we
need to send a command to switch the display on, and to determine the cursor
function. The Display Mode register is defined as shown below.
Clear Display
Before data can be written to the display, the display must be cleared, and the
cursor reset to the first character in the first row (or any other location that you
wish to write data to). The Clear Display command is shown below.
Sending display data to the LCD
The mbed TextLCD library
The TextLCD definition also tells the LCD object which pins are used for which functions.
The object definition is defined in the following manner:
TextLCD lcd(int rs, int e, int d0, int d1, int d2, int d3);
TextLCD lcd(p19, p20, p21, p22, p23, p24);
Using the mbed TextLCD library
/*Program Example 8.5: TextLCD library Helo World example
*/ #include "mbed.h"
#include "TextLCD.h"
TextLCD lcd(p19, p20, p21, p22, p23, p24); //rs,e,d0,d1,d2,d3
int main() {
lcd.printf("Hello World!");
}
/* Program Example 8.6: LCD Counter example
*/ #include "mbed.h“
#include "TextLCD.h“
TextLCD lcd(p19, p20, p21, p22, p23, p24); // rs, e, d0, d1, d2, d3 int x=0;
int main() {
lcd.printf("LCD Counter");
while (1) {
lcd.locate(5,1);
lcd.printf("%i",x);
wait(1);
x++;
}
}
/*Program Example 8.8: Displaying a formatted string on the NHD-C12832 */
#include "mbed.h" // Basic Library required for onchip peripherals #include
"C12832.h"
C12832 lcd(p5, p7, p6, p8, p11); // Initialize lcd
int main(){
int j=0;
lcd.cls(); // clear screen
while(1){
lcd.locate(10,10); // set location to x=10, y=10 lcd.printf("Counter :
%d",j); // print counter value j++; // increment j
wait(0.5); // wait 0.5 seconds }
}

More Related Content

Similar to _LCD display-mbed.pdf

DEF CON 23 - Rodringo Almeida - embedded system design from electronics
DEF CON 23 - Rodringo Almeida - embedded system design from electronics DEF CON 23 - Rodringo Almeida - embedded system design from electronics
DEF CON 23 - Rodringo Almeida - embedded system design from electronics Felipe Prado
 
Micro c lab6(lcd)
Micro c lab6(lcd)Micro c lab6(lcd)
Micro c lab6(lcd)Mashood
 
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
 
Calculator design with lcd using fpga
Calculator design with lcd using fpgaCalculator design with lcd using fpga
Calculator design with lcd using fpgaHossam Hassan
 
20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Jorisimec.archive
 
Embedded System Practical manual (1)
Embedded System Practical manual (1)Embedded System Practical manual (1)
Embedded System Practical manual (1)Niraj Bharambe
 
Tft touch screen manufacturers
Tft touch screen manufacturersTft touch screen manufacturers
Tft touch screen manufacturersKeatonParker2
 
Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015Rodrigo Almeida
 
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
 

Similar to _LCD display-mbed.pdf (20)

Lcd tutorial
Lcd tutorialLcd tutorial
Lcd tutorial
 
Picmico
PicmicoPicmico
Picmico
 
DEF CON 23 - Rodringo Almeida - embedded system design from electronics
DEF CON 23 - Rodringo Almeida - embedded system design from electronics DEF CON 23 - Rodringo Almeida - embedded system design from electronics
DEF CON 23 - Rodringo Almeida - embedded system design from electronics
 
Micro c lab6(lcd)
Micro c lab6(lcd)Micro c lab6(lcd)
Micro c lab6(lcd)
 
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...
 
Lcd n PIC16F
Lcd n PIC16FLcd n PIC16F
Lcd n PIC16F
 
Calculator design with lcd using fpga
Calculator design with lcd using fpgaCalculator design with lcd using fpga
Calculator design with lcd using fpga
 
20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris
 
Lab Activity 3
Lab Activity 3Lab Activity 3
Lab Activity 3
 
Embedded System Practical manual (1)
Embedded System Practical manual (1)Embedded System Practical manual (1)
Embedded System Practical manual (1)
 
Lcd interfacing
Lcd interfacingLcd interfacing
Lcd interfacing
 
arduinoedit.pptx
arduinoedit.pptxarduinoedit.pptx
arduinoedit.pptx
 
Tft touch screen manufacturers
Tft touch screen manufacturersTft touch screen manufacturers
Tft touch screen manufacturers
 
Microcontroller part 4
Microcontroller part 4Microcontroller part 4
Microcontroller part 4
 
LCD Interacing with 8051
LCD Interacing with 8051LCD Interacing with 8051
LCD Interacing with 8051
 
PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
 
Basic standard calculator
Basic standard calculatorBasic standard calculator
Basic standard calculator
 
Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015
 
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
 
Interfacing with LCD
Interfacing with LCDInterfacing with LCD
Interfacing with LCD
 

Recently uploaded

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 

Recently uploaded (20)

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 

_LCD display-mbed.pdf

  • 3.
  • 4.
  • 5.
  • 7.
  • 8.
  • 10. Using modular coding to interface the LCD display Our LCD.h header /* Program Example 8.1: LCD.h header file */ #ifndef LCD_H #define LCD_H #include "mbed.h" void toggle_enable(void); //function to toggle/pulse the enable bit void LCD_init(void); //function to initialise the LCD void display_to_LCD(char value); //function to display characters #endif
  • 11. Initialising the display wait a short period (approximately 20 ms), then set the RS and E lines to zero and then send a number of configuration messages to set up the LCD. We then need to send configuration data to the • Function Mode register • Display Mode register • Clear Display register In order to initialise the display.
  • 12. Initialising the display Function Mode To set the LCD function mode, the RS, R/|W and DB0-7 bits should be set as shown below. Remember in 4-bit mode, data bus values are sent as two nibbles.
  • 13. Display Mode The Display Mode control register must also be set up during initialisation. Here we need to send a command to switch the display on, and to determine the cursor function. The Display Mode register is defined as shown below.
  • 14. Clear Display Before data can be written to the display, the display must be cleared, and the cursor reset to the first character in the first row (or any other location that you wish to write data to). The Clear Display command is shown below.
  • 15. Sending display data to the LCD
  • 16.
  • 17.
  • 18. The mbed TextLCD library The TextLCD definition also tells the LCD object which pins are used for which functions. The object definition is defined in the following manner: TextLCD lcd(int rs, int e, int d0, int d1, int d2, int d3); TextLCD lcd(p19, p20, p21, p22, p23, p24);
  • 19. Using the mbed TextLCD library /*Program Example 8.5: TextLCD library Helo World example */ #include "mbed.h" #include "TextLCD.h" TextLCD lcd(p19, p20, p21, p22, p23, p24); //rs,e,d0,d1,d2,d3 int main() { lcd.printf("Hello World!"); }
  • 20. /* Program Example 8.6: LCD Counter example */ #include "mbed.h“ #include "TextLCD.h“ TextLCD lcd(p19, p20, p21, p22, p23, p24); // rs, e, d0, d1, d2, d3 int x=0; int main() { lcd.printf("LCD Counter"); while (1) { lcd.locate(5,1); lcd.printf("%i",x); wait(1); x++; } }
  • 21. /*Program Example 8.8: Displaying a formatted string on the NHD-C12832 */ #include "mbed.h" // Basic Library required for onchip peripherals #include "C12832.h" C12832 lcd(p5, p7, p6, p8, p11); // Initialize lcd int main(){ int j=0; lcd.cls(); // clear screen while(1){ lcd.locate(10,10); // set location to x=10, y=10 lcd.printf("Counter : %d",j); // print counter value j++; // increment j wait(0.5); // wait 0.5 seconds } }