Print On LCD
Program:
I Aim to teach you prgramming 16x2 LCD in simples language skills using pic18f4520.
Summary on LCD:
LCD means Liquid Crystal Display. Liquid Crystal Polarizes on potential drop across it hence blocking light passing through it.(black pixel). When no potential is dropped the LCD passes light hence white pixel.
16x2 means 16 columns and 2 rows of alphanumeric ASCII blocks on the LCD.
Has three control signals and one databus.
R/W: When this signal is '1' = Reads data from the LCD RAM. When this signal is '0' = Writes data on LCD RAM.
EN: Is basically a Latch signal. You have to send '1' first and then '0' signal with a particular delay to latch the data.
RS: Is a Register Select Control signal. When this signal is '1' = It accepts data to be displayed. When this signal is '0' = It accepts instructions for the LCD like setting font, cursor position etc.
D0 to D7: Is 8-bit Databus. It is used to send both data as well as Instructions to the LCD based upon control signals.
Backlight + and Backlight GND: Turns on Backlight of that LCD so that you can see the words correctly.
VEE: is a contrast voltage. Using a trim pot you can adjust the contrast of the LCD. More voltage more the contrast and vice versa(voltage should never exceed VCC = +5 volts).
This LCD has 2 lines and can write maximum 16 letter word per line.
That is all you have to know till now.
Next you should know how to connect a LCD to any microcontroller. For our demonstration I'm using pic18f4520. Check the circuit diagram below for details. Construct this circuit diagram. (Beware wrong connections on LCD or microcontroller can permanently damage the devices).
Hardware required:
1. JHD 162A 16x2 LCD
2. Pic18F4520 Microcontroller
3. 40 Pin ZIP Socket for microcontroller.
4. Tactile Switch
5. 41k ohms 1/4Watts resistor
//****************************************//
1. JHD 162A 16x2 LCD
2. Pic18F4520 Microcontroller
3. 40 Pin ZIP Socket for microcontroller.
4. Tactile Switch
5. 41k ohms 1/4Watts resistor
//****************************************//
//Author : Palak Patel(M.Tech)
//Contact No:9173211683
//Title:lcd_8bit
//Platform: PIC18f4520
//Software:Microchip PIC
#include<p18f4520.h>
#pragma config OSC = INTIO67
#pragma config FCMEN = OFF
#pragma config IESO = OFF
#pragma config PWRT = OFF
#pragma config BOREN = OFF
#pragma config WDT = OFF
#pragma config MCLRE = OFF
#pragma config PBADEN = OFF
#pragma config STVREN = OFF
#pragma config LVP = OFF
#define LCD PORTD
#define RS PORTCbits.RC0
#define RW PORTCbits.RC1
#define EN PORTCbits.RC2
void cmd(unsigned char);
void dat(unsigned char);
void Delay_ms(unsigned char p);
void main()
{
unsigned char P[ ]="Hello World",i;
TRISD=0x00;
TRISC = 0x00;
cmd(0x01);
cmd(0x80);
cmd(0x0C);
cmd(0x06);
cmd(0x38);
while(1)
{
while(P[i]!='\0')
{
dat(P[i]);
i++;
Delay_ms(100);
}
cmd(0x01);
i=0;
}
}
void cmd(unsigned char k)
{
LCD=k;
RS=0;
RW=0;
EN=1;
Delay_ms(20);
EN=0;
}
void dat(unsigned char k)
{
LCD=k;
RS=1;
RW=0;
EN=1;
Delay_ms(20);
EN=0;}
void Delay_ms(unsigned char p)
{
unsigned char i,j;
for(i=0;i<p;i++)
{
for(j=0;j<20;j++);
}
}
//****************************************//
Simulation:
For Basic Electronics Kindaly follow this Link:
http://basicelectonicspalakpatel.blogspot.in/2014/08/the-mosfet-as-switch.html
Sir please Write comment for it. so We can understand meaning of bits which you set
ReplyDeleteit is awesome for beginner..i need help for RS-485.....
ReplyDeleteneed help for ISR using timer1
ReplyDeleteMy friend you will get code for that soon..
Deleteawllaaa
ReplyDeleteWHAT SHOULD BE THE CODE FOR 4 BIT
ReplyDeleteThis isvery creative and informative blog, thanks for sharing. If you face issues with firestick no signal. Its Okay we provide a qualified team at fire stick customer service phone number for you to solve your issues.
ReplyDelete