control7 blog

~Electronics & Programming~

Skip to: Content | Sidebar | Footer

Pages

PIC tutorial, Easy LCD interfacing with PIC16F877

24 September, 2011 (20:35) | Electronics, PIC microcontroller | By: xenon ark

This is a very easy tutorial to connect a PIC with an LCD. The program is written by mikroC PRO 4.60 Check the LCD library from the library manager before compiling the program.

the program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
 
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_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,2,"PIC16F877A LCD");     // Write text in first row
  Lcd_Out(2,3,"control7.net");       // Write text in second row
}

The Schematic:

Demo run:


mikroC download

Download mikroC from here.

Write a comment





*
= 5 + 5