Forum Replies Created
Viewing 3 posts - 1 through 3 (of 3 total)
-
AuthorPosts
-
kiran kumar
ParticipantThank you Mr Bhatt.
kiran kumar
ParticipantThank you for the reply Mr Bhatt,
Is there any change in command or code with respect to the 8×2 and 16×2?
kiran kumar
Participant*******************MAIN.C*****************************
#include<htc.h>
__CONFIG(LVP_OFF & FCMEN_OFF & IESO_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS);#define RS RA5#define EN RA4#define D4 RC0#define D5 RC1#define D6 RC2#define D7 RC3#define _XTAL_FREQ 4000000#include “lcd.h”void main(){int i;TRISA = 0X00;TRISC = 0x00;Lcd4_Init();while(1){Lcd4_Set_Cursor(1,1);Lcd4_Write_String(“electroSome LCD Hello World”);for(i=0;i<15;i++){__delay_ms(1000);Lcd4_Shift_Left();}for(i=0;i<15;i++){__delay_ms(1000);Lcd4_Shift_Right();}Lcd4_Clear();Lcd4_Set_Cursor(2,1);//Lcd4_Write_String(“electroSome LCD Hello World”);Lcd4_Write_Char(‘e’);Lcd4_Write_Char(‘S’);__delay_ms(2000);}}*********************************LCD.H*******************************************//LCD Functions Developed by electroSome#ifndef D0#define D0 RB0#define D1 RB1#define D2 RB2#define D3 RB3#endif//LCD 8 Bit Interfacing Functionsvoid Lcd8_Port(char a){if(a & 1)D0 = 1;elseD0 = 0;if(a & 2)D1 = 1;elseD1 = 0;if(a & 4)D2 = 1;elseD2 = 0;if(a &D3 = 1;elseD3 = 0;if(a & 16)D4 = 1;elseD4 = 0;if(a & 32)D5 = 1;elseD5 = 0;if(a & 64)D6 = 1;elseD6 = 0;if(a & 128)D7 = 1;elseD7 = 0;}void Lcd8_Cmd(char a){RS = 0; // => RS = 0Lcd8_Port(a); //Data transferEN = 1; // => E = 1__delay_ms(5);EN = 0; // => E = 0}Lcd8_Clear(){Lcd8_Cmd(1);}void Lcd8_Set_Cursor(char a, char b){if(a == 1)Lcd8_Cmd(0x80 + b);else if(a == 2)Lcd8_Cmd(0xC0 + b);}void Lcd8_Init(){Lcd8_Port(0x00);RS = 0;__delay_ms(25);///////////// Reset process from datasheet /////////Lcd8_Cmd(0x30);__delay_ms(5);Lcd8_Cmd(0x30);__delay_ms(15);Lcd8_Cmd(0x30);/////////////////////////////////////////////////////Lcd8_Cmd(0x38); //function setLcd8_Cmd(0x0C); //display on,cursor off,blink offLcd8_Cmd(0x01); //clear displayLcd8_Cmd(0x06); //entry mode, set increment}void Lcd8_Write_Char(char a){RS = 1; // => RS = 1Lcd8_Port(a); //Data transferEN = 1; // => E = 1__delay_ms(4);EN = 0; // => E = 04}void Lcd8_Write_String(char *a){int i;for(i=0;a!=’