PIC18F4520 LCD example

In this example we connected an LCD to the LCD 1602 LCD connection on the Open18F4520 PIC evaluation development board from Waveshare. A simple example is to display some basic text on the LCD display. This is a picture of the development board

Open18F4520 development board

Taking a look at the schematics you will see the following for the LCD1602 connection, now MikroE C for Pic has a built in LCD library with an example, a little bit of tweaking can get this example up and running

waveshare lcd1602

Here is the connection

LCD RS pin is connected to RC4
LCD Enable pin is connected to RC6
LCD D4 pin is connected to RD4
LCD D5 pin is connected to RD5
LCD D6 pin is connected to RD6
LCD D7 pin is connected to RD7
LCD R/W pin which is RC5 is connected to a ground connector on the board (we could have done this in code as well)

Code

The code was written in MIkroc for Pic and uses the LCD libraries, its fairly easy to understand

// LCD module connections
sbit LCD_RS at RC4_bit;
sbit LCD_EN at RC6_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
 
sbit LCD_RS_Direction at TRISC4_bit;
sbit LCD_EN_Direction at TRISC6_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections
 
 
void main()
{
 
    Lcd_Init(); // Initialize LCD
    Lcd_Cmd(_LCD_CLEAR); // Clear display
    Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
    Lcd_Out(1,1,"Hello World");//Write text'Hello World' in first row
 
}

Links

 

PIC Board PIC18F4520-I/P PIC18F4520 PIC 8-bit RISC PIC Microcontroller Development Board +14 Accessory kits =Open18F4520 Pack-B

Share
SHARE
Previous articleDisplay LDR value on LCD connected to chipkit UNO
Next articlePIC18F4520 push button example