Summary of LCD Module Display 4 line For CSS Compiler
This article provides a PIC16F877 microcontroller C code snippet for an educational project demonstrating LCD interfacing. The program initializes an 8-bit ADC, displays a welcome screen with technical details, and then loops to show four predefined integer values on the LCD display in hexadecimal-to-BCD format.Parts used in the Electrical Power Display Project:
- PIC16F877 Microcontroller
- LCD Module (4-bit interface)
- C Compiler for PIC (CCS)
- Lcd_4bit.c Library File
#include <16F877.h>
#device adc=8
#fuses NOWDT,HS, NOPUT, NOPROTECT, BROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG
#use delay(clock=4000000)
#include <Lcd_4bit.c>
int16 value1,value2,value3,value4;
void main(){
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
set_tris_d(0x00);
lcd_init();
lcd_row_col(1,0);
lcd_putc("Electrical Power");
delay_ms(20);
lcd_row_col(2,0);
lcd_putc("Loei Technical ");
delay_ms(20);
lcd_row_col(3,0);
lcd_putc("www.kchimicro ");
delay_ms(20);
lcd_row_col(4,0);
lcd_putc("Pic controller ");
delay_ms(5000);
lcd_Clear();
lcd_init();
while(true){
value1 = 2568;
value2 = 1278;
value3 = 8887;
value4 = 9997;
//==================================
lcd_row_col(1,0);
Lcd_putc("value1=");
hex_bcd(value1);lcd_row_col(1,8);sent_Lcd();
delay_ms(30);
//==================================
lcd_row_col(2,0);
Lcd_putc("Value2=");
hex_bcd(value2);lcd_row_col(2,8);sent_Lcd();
delay_ms(30);
//==================================
lcd_row_col(3,0);
Lcd_putc("Value3=");
hex_bcd(value3);lcd_row_col(3,8);sent_Lcd();
delay_ms(30);
//==================================
lcd_row_col(4,0);
Lcd_putc("Value4=");
hex_bcd(value4);lcd_row_col(4,8);sent_Lcd();
delay_ms(30);
lcd_row_col(4,13);
Lcd_putc("mat");
delay_ms(30);
}
}
-
What microcontroller is used in this code?
The code uses the PIC16F877 microcontroller as indicated by the include statement. -
How many bits is the ADC configured for?
The ADC is set to 8 bits using the device directive #device adc=8. -
What library file is included for the LCD?
The project includes the Lcd_4bit.c library file. -
What clock speed is set for the delay function?
The delay is configured for a 4000000 Hz clock frequency. -
Does the code use analog inputs?
No, the setup_adc_ports function explicitly sets NO_ANALOGS. -
How are the values displayed on the LCD?
The values are converted using hex_bcd and sent to the LCD via sent_Lcd. -
What text appears on the first line of the initial display?
The text Electrical Power is displayed on the first row. -
What happens after the welcome screen is shown?
The LCD is cleared and the main loop begins displaying variable values.
Related projects
PICDEM FS USB Mass Storage Device using PIC18F4550 with Proteus Simulation
Introduction This microcontroller project demonstrates how to simulate a USB Mass Storage Device (MSD) using the PIC18F4550 in a Proteus simulation environment....
Peripheral TutorialsHands-On Digital I/O Lab with PIC18F46K22 Microcontroller
PIC18F46K22 Microcontroller Digital I/O specifically explores the design of simple combinational circuits using the digital I/O capabilities of the PIC18F46K22 microcontroller. Moving...
Peripheral TutorialsDesign for manufacturing and assembly: DFA&DFM
Product developers understand the challenges involved in creating a market-ready product. Even experienced designers often go through multiple prototype iterations before reaching...
Peripheral Tutorials · PIC16F877AKeypad 4×5 for microcontrollers v. 1.1 using PIC16F877
What's this? The circuit here described is a simple 4x5 keypad that can be used in particular with the PIC 16F877 microcontroller,...
Peripheral TutorialsMatrix scankey 3×4 for Lcd 2 line For CSS Compiler
Peripheral Tutorials · PIC16F877APIC16F877 timer1 code and Proteus simulation
This PIC16F877 microcontroller tutorial answers the question, " How to use timer1 of PIC16F877 and how to handle its interrupts? " Using...