336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

https://electrosome.com/interfacing-lcd-with-pic-microcontroller-hi-tech-c/


Interfacing-LCD-with-PIC-Microcontroller-Hi-Tech-C.zip

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 Functions

void Lcd8_Port(char a)

{

if(a & 1)

D0 = 1;

else 

D0 = 0;

if(a & 2)

D1 = 1;

else

D1 = 0;

if(a & 4)

D2 = 1;

else

D2 = 0;

if(a & 8)

D3 = 1;

else

D3 = 0;

if(a & 16)

D4 = 1;

else

D4 = 0;


if(a & 32)

D5 = 1;

else

D5 = 0;

if(a & 64)

D6 = 1;

else 

D6 = 0;

if(a & 128)

D7 = 1;

else

D7 = 0;

}

void Lcd8_Cmd(char a)

  RS = 0;             // => RS = 0

  Lcd8_Port(a);             //Data transfer

  EN  = 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 set

  Lcd8_Cmd(0x0C);    //display on,cursor off,blink off

  Lcd8_Cmd(0x01);    //clear display

  Lcd8_Cmd(0x06);    //entry mode, set increment

}


void Lcd8_Write_Char(char a)

{

   RS = 1;             // => RS = 1

   Lcd8_Port(a);             //Data transfer

   EN  = 1;             // => E = 1

  __delay_ms(4);

   EN  = 0;             // => E = 04

}


void Lcd8_Write_String(char *a)

{

int i;

for(i=0;a[i]!='\0';i++)

Lcd8_Write_Char(a[i]);

}


void Lcd8_Shift_Right()

{

Lcd8_Cmd(0x1C);

}


void Lcd8_Shift_Left()

{

Lcd8_Cmd(0x18);

}

//End LCD 8 Bit Interfacing Functions


//LCD 4 Bit Interfacing Functions


void Lcd4_Port(char a)

{

if(a & 1)

D4 = 1;

else 

D4 = 0;

if(a & 2)

D5 = 1;

else

D5 = 0;

if(a & 4)

D6 = 1;

else

D6 = 0;

if(a & 8)

D7 = 1;

else

D7 = 0;

}

void Lcd4_Cmd(char a)

RS = 0;             // => RS = 0

Lcd4_Port(a);

EN  = 1;             // => E = 1

  __delay_ms(4);

  EN  = 0;             // => E = 0

}


Lcd4_Clear()

{

Lcd4_Cmd(0);

Lcd4_Cmd(1);

}


void Lcd4_Set_Cursor(char a, char b)

{

char temp,z,y;

if(a == 1)

{

 temp = 0x80 + b;

z = temp>>4;

y = (0x80+b) & 0x0F;

Lcd4_Cmd(z);

Lcd4_Cmd(y);

}

else if(a == 2)

{

temp = 0xC0 + b;

z = temp>>4;

y = (0xC0+b) & 0x0F;

Lcd4_Cmd(z);

Lcd4_Cmd(y);

}

}


void Lcd4_Init()

{

Lcd4_Port(0x00);

   __delay_ms(20);

  Lcd4_Cmd(0x03);

__delay_ms(5);

  Lcd4_Cmd(0x03);

__delay_ms(11);

  Lcd4_Cmd(0x03);

  /////////////////////////////////////////////////////

  Lcd4_Cmd(0x02);    

Lcd4_Cmd(0x02);

  Lcd4_Cmd(0x08);

Lcd4_Cmd(0x00); 

Lcd4_Cmd(0x0C);     

  Lcd4_Cmd(0x00);    

  Lcd4_Cmd(0x06);   

}


void Lcd4_Write_Char(char a)

{

   char temp,y;

   temp = a&0x0F; 

   y = a&0xF0;

RS = 1;             // => RS = 1

   Lcd4_Port(y>>4);             //Data transfer

EN = 1;

__delay_ms(5);

EN = 0;

Lcd4_Port(temp);

EN = 1;

__delay_ms(5);

EN = 0;

}


void Lcd4_Write_String(char *a)

{

int i;

for(i=0;a[i]!='\0';i++)

Lcd4_Write_Char(a[i]);

}


void Lcd4_Shift_Right()

{

Lcd4_Cmd(0x01);

Lcd4_Cmd(0x0C);

}


void Lcd4_Shift_Left()

{

Lcd4_Cmd(0x01);

Lcd4_Cmd(0x08);

}

//End LCD 4 Bit Interfacing Functions

▲▲▲▲▲

Posted by ElectricShock
:
BLOG main image
잡동사니들(지극히 개인취향인...) (다른글에도 댓글 부탁해요♥) You May Leave English Messages on GuestBook. by ElectricShock

공지사항

카테고리

분류 전체보기 (782)
Programming(=프로그래밍) (3)
MiDi (2)
Animation (4)
Blender (3D Graphic Program.. (10)
Blendtuts.com (Series) (1)
Blender 기초 팁들 (2)
Processing (디지털미디어과) (2)
Music (1)
Books in the world (0)
Communication(CAN, UART, et.. (12)
MCU Examples (PIC 기반) (7)
Transistor (1)
Mikro C Pro (11)
Mikro Pascal (1)
Proton IDE (0)
Robot (0)
Swift 3D (1)
Dummies Series (1)
All about Hacking (0)
제2 외국어 (1)
PIC 해외서적들 (3)
AVR (25)
PIC (MikroC) (MPLAB) (4)
Assembly (2)
ARM (3)
Arduino (26)
PSpice (1)
Proteus ISIS (14)
CodeVision (2)
FPGA (15)
MPLAB (24)
PCB (the Procedure) (15)
3D Printer (5)
PICKIT3 (6)
Matlab (11)
RaspBerry PI (15)
BeagleBone (1)
Android Studio (17)
졸업작품 (172)
Korea History (0)
Issue(사회) (73)
Multimeter 리뷰 (1)
Oscilloscope (1)
A (34)
B (19)
J (6)
C (32)
P (12)
T (37)
H (12)
I (12)
M (44)
R (5)
E (5)
F (2)
D (9)
O (2)
L (7)
S (9)
W (2)
V (6)
G (14)
Visual C++ or Visual Studio (2)
Android App Development (0)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백