Showing posts with label LCD and KEYPAD interfacing. Show all posts

Moving message display using lcd

It is one of the famous project in electronics.
It is also known as scrolling LCD display. 



This is the circuit diagram of moving message display. I have simulated this project on proteus as well as on hardware. Its very simple. You are just required to know about LCD interfacing.
As we know that lcd is given command to decide what and where we want to display on lcd. 
There is a command 1CH that is given to lcd for shifting entire display to right. If we apply this command for 6 or 7 times then display is automatically moving in right direction. It will move in left direction on proteus but it moves in right direction when implementing on hardware.

Assembly Language program to display pressed key on LCD



Display pressed key on lcd:

/************************************************************************************/
//            PROGRAM TO  DEMONSTRATE  INTERFACING OF HEX DISPALY WITH MCS51       
/************************************************************************************/


ORG 0000H


/************************************************************************************/
/*                                           I/O PIN INITIALISATIONS AND DECLARATIONS                                                                                                                   */
/************************************************************************************/

C1 EQU P2.0
C2 EQU P2.1
C3 EQU P2.2
C4 EQU P2.3
ROW1 EQU P2.4
ROW2 EQU P2.5
ROW3 EQU P2.6
ROW4 EQU P2.7
LCD EQU P0
RS EQU P1.0
RW EQU P1.1
EN EQU P1.2
MOV LCD,#80H
ACALL CMD
ACALL DELAY
MOV LCD,#08H
ACALL CMD
ACALL DELAY
MOV LCD,#01H
ACALL CMD
ACALL DELAY
MOV LCD,#0EH
ACALL CMD
ACALL DELAY
MOV LCD,#80H
ACALL CMD
ACALL DELAY
MOV P2,#00H
MOV P0,#00H
MOV DPTR,#MSG
CLR A
MOV B,#00H
MOV R3,#00H

MOV R0,#02
H2: ACALL KEYPAD
DJNZ R0,H2
MOV LCD,#'='
ACALL DISP
ACALL DELAY
MOV A,R4
MOV B,#10
MUL AB
ADD A,R5
MOV B,#10
DIV AB
MOV DPTR,#MSG
MOVC A,@A+DPTR
MOV LCD,A
ACALL DISP
ACALL DELAY
MOV A,B
MOV DPTR,#MSG
MOVC A,@A+DPTR
MOV LCD,A
ACALL DISP
ACALL DELAY
ALT: SJMP ALT

/************************************************************************************/
/*                                           READING COLUMN VALUE                                                                                                                                                                                                          */
/************************************************************************************/


KEYPAD:ACALL DELAY           
       MOV P2, #0FH
                   ACALL DELAY
K1:             MOV A,P2
                   CJNE A,#0FH,KK1
                   SJMP K1
KK1:   JB C1,N1
                   MOV B,#00h
                   ACALL DELAY
N1:            JB C2,N2
                   MOV B,#01h
                   ACALL DELAY
N2:            JB C3,N3
                   MOV B,#02h
                   ACALL DELAY
N3:            JB C4,N4
                   MOV B,#03h
                   ACALL DELAY

/************************************************************************************/
/*                                           READING ROW VALUE                                                                                                                                                                                                                   */
/************************************************************************************/
                              
N4:   MOV P2, #0F0H
K11:  MOV A,P2
                  CJNE A,#0F0H,KK11
                  SJMP K11
KK11: ACALL DELAY
                  JB ROW1,NR1
                  MOV R3,#00h
                  ACALL DELAY
NR1:  JB ROW2,NR2
                  MOV R3,#04h
                  ACALL DELAY
NR2:  JB ROW3,NR3
                  MOV R3,#08h
                  ACALL DELAY
NR3:  JB ROW4,NR4
                  MOV R3,#0Ch
                  ACALL DELAY
NR4:  MOV A,R3

/************************************************************************************/
/*                           SENDING KEYVALUE TO PORT 0 AND SERAIL PORT                                                                                                                                            */
/************************************************************************************/
                 
                  ADD A,B
                  CJNE R0,#02,H3
                  MOV R4,A
                  H3: CJNE R0,#01,H4
                  MOV R5,A
                 
  H4: MOVC A,@A+DPTR
                  MOV LCD,A
                  ACALL DISP
                  ACALL DELAY
                  CLR A
                  RET

/************************************************************************************/
/*                                           DELAY SUBROUTINE                                                                                                                                                                                                                       */
/************************************************************************************/


DELAY:  MOV R1,#5FH
a1:     MOV R2,#0FEH
a2:     DJNZ R2,a2
        DJNZ R1,a1
                    RET

CMD:     CLR RS
        CLR RW
                                SETB EN
                                NOP
                                CLR EN
                                RET
DISP:   SETB RS
        CLR RW
                                SETB EN
                                NOP
                                CLR EN
                                RET

/************************************************************************************/
/*                                           LOOKUP TABLE W.R.T 0-15 SWITCHES IN HEX KEYPAD                                                                                                     */
/************************************************************************************/

MSG: DB '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',0

      END

Display pressed key on LCD using 8051 microcontroller

                               


This is a mini project. It is very simple and easy. You are just required to know about the LCD and Keypad interfacing.
Connect the LCD and keypad to microcontroller according to the circuit diagram, I have defined hex value for each key like

                              0 1 2 3
                              4 5 6 7
                              8 9 A B
                              C D E F

 Logic is very simple. It is waiting for key to be pressed. After pressing the hex value for equivalent value is stored in a register and equivalent ASCII value is sent to the LCD to be displayed because LCD always display ASCII value. I have written program in assembly language.

- Copyright © Microcontroller Projects -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -