SlideShare a Scribd company logo
LCD display-MBED
Dr.M.Vidhyalakshmi
SRMIST/RMP
LCD DISPLAY
_LCD display-mbed.pdf
_LCD display-mbed.pdf
_LCD display-mbed.pdf
PC1602F
_LCD display-mbed.pdf
_LCD display-mbed.pdf
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
_LCD display-mbed.pdf
_LCD display-mbed.pdf
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

PDF
Experiment 16 x2 parallel lcd
DOCX
Est 8 1 st
PPTX
LCD Interacing with 8051
PPTX
Lcd interfacing with microprocessor 8051
PPT
Lcd interface with atmega32 avr best.ppt
PPT
Lcd interfacing1
PDF
Microcontroladores: Interfaz del microcontrolador 8051 con LCD usando el simu...
PPTX
LCD_Example.pptx
Experiment 16 x2 parallel lcd
Est 8 1 st
LCD Interacing with 8051
Lcd interfacing with microprocessor 8051
Lcd interface with atmega32 avr best.ppt
Lcd interfacing1
Microcontroladores: Interfaz del microcontrolador 8051 con LCD usando el simu...
LCD_Example.pptx

Similar to _LCD display-mbed.pdf (20)

DOC
Moving message display
DOCX
Lcd interfacing
PPTX
131080111003 mci
PDF
04 Interfacing LCD Displays.2016
PDF
08_lcd.pdf
PDF
DEF CON 23 - Rodringo Almeida - embedded system design from electronics
PDF
Microcontroller part 4
DOCX
Alp lcd
PPTX
ESD -DAY 24.pptx
PDF
Lcd tutorial
PPTX
Micro c lab6(lcd)
PPTX
Embedded systems design @ defcon 2015
PPTX
LCD (2).pptx
PDF
AVR_Course_Day5 avr interfaces
PPTX
LCD Theory and Working Principles
PDF
Learn LCD Arduino-v1
PDF
Interfacing with LCD
DOCX
Lab Activity 3
PDF
Embedded C Programming Module 7 Presentation
Moving message display
Lcd interfacing
131080111003 mci
04 Interfacing LCD Displays.2016
08_lcd.pdf
DEF CON 23 - Rodringo Almeida - embedded system design from electronics
Microcontroller part 4
Alp lcd
ESD -DAY 24.pptx
Lcd tutorial
Micro c lab6(lcd)
Embedded systems design @ defcon 2015
LCD (2).pptx
AVR_Course_Day5 avr interfaces
LCD Theory and Working Principles
Learn LCD Arduino-v1
Interfacing with LCD
Lab Activity 3
Embedded C Programming Module 7 Presentation
Ad

Recently uploaded (20)

PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Cell Structure & Organelles in detailed.
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Institutional Correction lecture only . . .
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Classroom Observation Tools for Teachers
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Lesson notes of climatology university.
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Renaissance Architecture: A Journey from Faith to Humanism
O7-L3 Supply Chain Operations - ICLT Program
102 student loan defaulters named and shamed – Is someone you know on the list?
Final Presentation General Medicine 03-08-2024.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Anesthesia in Laparoscopic Surgery in India
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Cell Structure & Organelles in detailed.
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Institutional Correction lecture only . . .
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Classroom Observation Tools for Teachers
Sports Quiz easy sports quiz sports quiz
PPH.pptx obstetrics and gynecology in nursing
01-Introduction-to-Information-Management.pdf
Lesson notes of climatology university.
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Ad

_LCD display-mbed.pdf

  • 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
  • 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 } }