March 11, 2012

How to Input Data Mikrokontroler Using Keypad

There are several ways to input the data on the microcontroller one of them is KEYPAD. There are many types of keypads one example discussed here uses a 4x4 matrix keypad.

This a keypad configuration using the keypad matrix 4x4 to Portb microcontroller.


$regfile = "m8535.dat"
$crystal = 12000000
$sim
'------------------------  lcd -------------------------------------------------
Config Lcd = 16 * 2
Config Lcdpin = Pin , Rs = Pina.0 , E = Pina.1 , Db4 = Pina.4 , Db5 = Pina.5 , Db6 = Pina.6 , Db7 = Pina.7

Dim Keyread As Byte
Dim Key As string * 1
Config Kbd = Portb , Debounce = 40
cls
locate 1 , 3
lcd "Key Pressed"

Do
    Keyread = Getkbd()
        If Keyread < 16 Then Gosub Getkey
Loop

Getkey:
    print keyread
    Key = Lookupstr(keyread , Dta)
    locate 2 , 8
    lcd key
Return

Dta:
    Data "1" , "2" , "3" , "A" , "4" , "5" , "6" , "B" , "7" , "8" , "9" , "C" , "*" , "0" , "#" , "D"

note:
  • When no key is pressed then the value to be received is 16
  • We can series resistor with a value of 470 - 1K

2 comments:

  1. mas mau tanya itukan nanti di layar lcd cuma nampil 1 angka kalu mau menampilkan 15 angka gmana mas??trima kasih sebelumnya

    ReplyDelete
  2. ditunggu aja ya codingnya. ntar saya bagi. Kalo sekarang lagi masih banyak kerjaan

    ReplyDelete

Let's us sharing

Recent Comment

Grab This Widget