The mikroC PRO for PIC provides a library for communication with LCDs (with HD44780 compliant controllers) through the 4-bit interface.
HD44780 Pinout
- Vss (Ground)
- VCC (5V)
- Contrast (use a potentiometer for variable contrast, or just connect to GND)
- Register Select (RS), 0 = command write, 1 = data write
- Read/Write (R/W), 0 = write to display, 1 = read from display
- Enable (EN) - used to clock in data
- DB0 (not used in 4-bit mode) - LSb
- DB1 (not used in 4-bit mode)
- DB2 (not used in 4-bit mode)
- DB3 (not used in 4-bit mode)
- DB4 - LSb in 4-bit mode
- DB5
- DB6
- DB7 - MSb
- Backlight + (5V)
- Backlight - (GND)
4-bit and 8-bit modes
An
HD44780 LCD can be operated in two different modes: 4-bit mode and
8-bit mode. In 8-bit mode, pins 7-14 of the LCD are connected to eight
I/O pins on the microcontroller; while in 4-bit mode, pins 11-14 on the LCD are connected to four I/O pins on the microcontroller.
The advantage to operating in 8-bit mode is that the programming is a
bit simpler and data can be updated more quickly. The obvious reason to
operate in 4-bit mode is to save four I/O pins on the PIC microcontroller.
Circuit Diagram for 16x2 LCD
Complete Circuit Diagram with PIC Microcontroller
MikroC Code:
// 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() {
int i=0;
char text[]="16x2 LCD Disply";
ADCON1=0x06; // Configure all input and output in to digital
Lcd_init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR);
// Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
// Cursor off
do{
Lcd_Out(1,1," Electronic
"); //Write text
on raw 1, column 1
Lcd_Out(2,1," Work Space
"); //Write text
on raw 1, column 1
Delay_ms(1000); // Delay 1 second
Lcd_Cmd(_LCD_CLEAR); // Clear display
for(i=0;i<16;i++){
Lcd_Chr(1,i+1,text[i]); //Display charactor by charactor
Delay_ms(500);
}
}while(1); // continue infinite loop
}
Such a appears to be fully very best. Each one of these very little facts usually are constructed combined with many qualifications facts. I prefer of which a whole bunch. gecey.com/transparent-monitor
ReplyDelete