Tag Archives: keyboard lewat 8951

Deteksi Tombol Keyboard lewat Mikrokontroller 8951

Aplikasi Detail ada di http://deatronik.com

Detail Programnya Keyboard with mikrokontroler Sebagai Berikut :

dispclr  equ 00000001b
funcset  equ 00111000b
entrmod  equ 00000110b
dispon   equ 00001100b
KbdData  bit P3.3
KbdClock bit INT0;P3.2
DataKeyboard equ 30h
;
org 0h
nop
call init_LCD
;
Forever:
JB KbdClock,$
call GetDataKeyboard
jnc Forever
acall LCD_Out
clr C
sjmp Forever
;
;==================================
;Subroutine Get Data From Keyboard
;==================================
GetDataKeyboard:
call Get_scancode
cjne a,#0F0h,kybd_pressed
JB KbdClock,$
call Get_Scancode
Setb C
call Convert_Scancode
ret
;
Kybd_pressed:
Clr C
ret
;
;===============================
;Subroutine Convert Scan Data
;Using Look Up Table
;===============================
Convert_ScanCode:
Mov DPTR,#TableKeyboard
movc A,@A+DPTR
mov DataKeyboard,A
ret
;
LCD_Out:
mov R7, #80h
acall write_inst
mov R7,DataKeyboard
acall write_data
ret
;
init_lcd:
mov R7,#dispclr
acall write_inst
mov R7,#funcset
acall write_inst
mov R7,#dispon
acall write_inst
mov R7,#entrmod
acall write_inst
ret
;
Get_scanCode:
clr A
Jnb KbdClock,$
mov R0,#08h
Get_ScanCode2:
Jb KbdClock,$
Mov C,KbdData
Rr A
mov acc.7,C
Jnb KbdClock,$
Djnz R0,Get_ScanCode2
Jb KbdClock,$
Jnb KbdClock,$
Jb KbdClock,$
Jnb KbdClock,$
ret
;
Write_inst:
Clr P3.6  ; RS = 0,
Mov P0,R7 ; D7 s/d D0 = P0 = R1
Setb P3.7 ; EN = 1
call delay; call delay time
Clr P3.7  ; EN = 0
ret
;
Write_data:
Setb P3.6 ; RS = 1,
Mov P0,R7 ; D7 s/d D0 = P0 = R1
Setb P3.7 ; EN = 1
call delay; call delay time
Clr p3.7  ; EN = 0
ret
;
delay:   mov R5,#0
delay1:mov R4,#02fh
djnz R4,$
djnz R5,delay1
ret
;
TableKeyboard:
DB 00
DB 0F9H
DB 00
DB 0F5H,0F3H,0F1H,0F2H,0FCH
DB 00H
DB 0FAH,0F8H,0F6H,0F4H
DB 0C0H
DB ‘~’
DB 00H
DB 00H
DB 0C1H
DB 0C2H
DB 00H
DB 0C3H
DB ‘Q1’
DB 00H,00H,00H
DB ‘ZSAW2’
DB 00H,00H
DB ‘CXDE43’
DB 00H,00H
DB ‘ VFTR5’
DB 00H,00H
DB ‘NBHGY6’
DB 00H,00H,00H
DB ‘MJU78’
DB 00H,00H
DB ‘,KIO09’
DB 00H,00H
DB ‘./L;P-‘
DB 00H,00H,00H
DB 27H
DB 00H
DB ‘[=’
DB 00H,00H
DB 0C5H
DB 0C6H
DB 0AH
DB ‘]’
DB 00H
DB ‘\’
DB 00H,00H,00H,00H,00H,00H,00H,00H
DB 08H
DB 00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H
DB 00H,00H
DB 0DH
DB 00H
DB 0FBH
DB 00H,00H,00H,00H,00H,00H,00H,00H,00H,00H
DB 0F7H
end