Você está na página 1de 3

LCD Interface has 16 lines. Only pin numbers 1 to 14 will be used in this experiment.

Connections:
Pin 1 (Vss) Connect it to GND
Pin 2 (Vdd) Connect it to 5V
Pin 3 (V0) Connect it to middle leg of 10K potentiometer (variable resistor). Connect the other end of
potentiometer to GND.
Pin 4 (RS) Connect it to GPIO pin
Pin 5 (RW) Connect it to GPIO pin
Pin 6 (E) Connect it to GPIO pin
Pin 7 to 14 (D0 to D7) 8 Data pins Connect it to 8 GPIO pins

Information sent to LCD display is classified as Control (Example: Clear screen) and Data (Example: 'A').
To send a command:
-> Put the command value in pins connected to D0...D7 [D0 LSB and D7 MSB]
-> Make RS pin LOW and RW pin LOW
-> Make E pin HIGH and after a delay (say delay(10)) make it LOW

To send a data:
-> Put the ascii value of character (say 67 for diplaying A) in pins connected to D0...D7 [D0 LSB and D7
MSB]
-> Make RS pin HIGH and RW pin LOW
-> Make E pin HIGH and after a delay (say delay(10)) make it LOW
int rspin=____, rwpin=_____, epin=____;
int dataPins[] = {__________};

void sendCmd(unsigned char cmd)


{
// Put the command value in dataPins

// Make RS pin LOW and RW pin LOW

// Make E pin HIGH and after a delay (say delay(10)) make it LOW
}

void sendData(unsigned char d)


{
// Put the value “d” in dataPins

// Make RS pin HIGH and RW pin LOW

// Make E pin HIGH and after a delay (say delay(10)) make it LOW
}

int j=100;
void setup() {
// initialize dataPins, rspin, rwpin, epin as output pins.

// Send Command 0x38 and give a delay

// Send Command 0x0f and give a delay

// Send Command 0x01 and give a delay

// Send Command 0x81 and give a delay

void loop() {
// Send Data ‘A’ and give a delay
}
Hex Code Command to LCD Instruction Register

0F LCD ON, cursor ON

01 Clear display screen

02 Return home

04 Decrement cursor (shift cursor to left)

06 Increment cursor (shift cursor to right)

05 Shift display right

07 Shift display left

0E Display ON, cursor blinking

80 Force cursor to beginning of first line

C0 Force cursor to beginning of second line

38 2 lines and 5×7 matrix

83 Cursor line 1 position 3

3C Activate second line

08 Display OFF, cursor OFF

C1 Jump to second line, position 1

OC Display ON, cursor OFF

C1 Jump to second line, position 1

C2 Jump to second line, position 2

Você também pode gostar