Quantcast
Viewing all articles
Browse latest Browse all 215

Interfacing 16x2 LCD with ARM Microcontroller

Image may be NSFW.
Clik here to view.
Interfacing-LCD-ARM-microcontroller-LPC2124
Interfacing LCD with ARM Microcontroller
Interfacing LCD with Microcontrollers holds a very important place in interfacing tutorials since LCD's help us to achieve a cheap Embedded Design with vital information display. This tutorial teaches you about designing and programming of LCD using LPC2124 Microcontroller.

16x2 LCD:

Image may be NSFW.
Clik here to view.
16x2-lcd-pin-diagram
16x2 LCD Pin diagram
This type of LCD is very common consists of 16 columns and two rows. The pin diagram of a 16x2 LCD was shown in the above diagram where DB0 - DB7 forms the data pins, RS - Register select,  En- Enable and RW - Read/Write. The detailed pin functions was given in the table below.
Image may be NSFW.
Clik here to view.
pin-description-16x2-lcd-pins
Pin description
Operation of LCD takes place by means of two inputs one is command and the other one is data. Command makes the LCD to perform actions such as cursor blink, cursor position , LCD on/off etc. Whereas Data will give a specific character to be displayed in the LCD screen.

COMMANDS FOR LCD:

The below table gives the basic commands and its respective operation a LCD will perform.
Image may be NSFW.
Clik here to view.
Command-table-16x2-lcd-display
Command table

DATA/COMMAND TRANSMISSION TO THE LCD:

The data and command transmission to the LCD will flow through the pins DB0-DB7, however the state of the RS pin will decide that the transmitted byte whether a data or command.
  • RS = 0 for command transmission.
  • RS = 1 for Data Transmission.
  • Then pulse the enable pin from high to low that is EN=1 to EN=0 with specific time delay between. Note that pulsing enable have to done for both data and Command transmission.

CODE:

The below code was built using Keil uVision 4 IDE. In the below code a a word "GADGETRONICX" was displayed and then made to scroll continuously using the command "0x18".

  1. #include<lpc21xx.h>
  2. unsigned char text[12]="GADGETRONICX";
  3. void lcd(char a,int b);
  4. void delay(void);
  5. int main(void)
  6.   {
  7.         int i;
  8. PINSEL0=0;
  9. IODIR0=0x000003ff;          //Set directions
  10. lcd(0x38,0);
  11. lcd(0x0f,0);
  12. for(i=0;i<=11;i++)
  13. lcd(text[i],1);
  14. while(1)
  15. {
  16. lcd(0x18,0);                     //Shift to right
  17. delay();
  18. }
  19.   }
  20. void lcd(char a,int b)
  21.   {
  22.   IOSET0=a<<0;
  23. IOSET0=b<<8;
  24. IOSET0=1<<9;
  25. delay();
  26. IOCLR0=1<<9;
  27. IOCLR0=b<<8;
  28. IOCLR0=a<<0;
  29.   }
  30. void delay(void)
  31.   {
  32.   unsigned int j;
  33. for(j=0;j<=10000;j++);
  34.   }
Like this tutorial? Share this with others through social sites and do not forget to follow or subscribe for more of these to your timeline/inbox.

Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 215

Trending Articles