Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 3rd February 2004, 11:46 PM   (permalink)
Default Help About scan 3x4 Keypad

I am tring to scan 3x4 keypad and I tried many ways but I did not success
So I need a sub routin that can scan 3x4 keypad without interrupt
I made search on the net but I did not finde what I need
Could you Please help me.
TronicBrain is offline  
Old 4th February 2004, 06:43 AM   (permalink)
Default Re: Help About scan 3x4 Keypad

Quote:
Originally Posted by beginner
I am tring to scan 3x4 keypad and I tried many ways but I did not success
So I need a sub routin that can scan 3x4 keypad without interrupt
I made search on the net but I did not finde what I need
Could you Please help me.
One of my PIC tutorials at http://www.winpicprog.co.uk shows how to scan a keypad, it actually uses a 4x4 but shows the lines which need removing for a 3x4.
Nigel Goodwin is offline  
Old 5th February 2004, 11:38 PM   (permalink)
Default

Thank you very much Nigel
It's really usefull PIC tutorials and I think I will get what I need :idea:
TronicBrain is offline  
Old 6th February 2004, 01:41 AM   (permalink)
Default

Code:
Define  LCD_DREG       PORTD 
Define  LCD_DBIT       4 
Define  LCD_RSREG      PORTE 
Define  LCD_RSBIT       0 
Define  LCD_EREG       PORTE 
Define  LCD_EBIT         1 

ADCON1 = 7          ' PORTA AND PORTE DIGITAL 
OPTION_REG.7 = 0   ' PORTB Pullups. 

TRISB = %11110000  ' PORTB 0-3 output, 4-7 input  
PORTB = 0 
TRISC = 0 
PORTC = 1 

'******************* 
keybuf var byte[4] 
keycnt var byte 
for keycnt = 0 to 4 
    keybuf[keycnt] = 0 
next 
'******************* 

key  var byte 
col  var byte 
row  var byte 
delay var byte 

delay = 0 

pause 100        
lcdout $fe,1,"4X4-KEYPAD DEMO",$fe,$c0,"2003 - by F.San" 

Main: 
    gosub Chk_KEYPAD 
    if PORTC = 0 then PORTC = 1 
    if delay = 100 then PORTC = PORTC << 1 
    delay  = delay + 1 
    pause 1 
goto Main 

Chk_KEYPAD: 
    for col = 0 to 3 
        PORTB = (dcd col) ^ $f    
        row = PORTB >> 4 
        if row != $f then   ' key pressed 
            key = (col * 4) + (ncd (row ^ $f)) 
            gosub DeBounce 
            gosub Got_KEY 
            key = 0 
        endif 
    next 
return    

DeBounce: 
    delay = 0 
    while (row != $f) and (delay < 20) 
        pause 10 
        delay = delay + 1 
    wend 
    delay = 0 
return 

Got_KEY: 
    'lcdout $fe,1,"4X4-KEYPAD DEMO",$fe,$c0,"BUTTON: ",#key 
    PORTC = key 

'******************* 
    if keycnt > 3 then 
       lcdout $fe,1 
       keycnt = 0 
    endif 
    keybuf[keycnt] = key 
    lcdout #keybuf[keycnt] 
    keycnt = keycnt + 1 
'******************* 
return 

end

if u are interested in basic
xjackal is offline  
Old 6th February 2004, 03:08 PM   (permalink)
Default

583 words to scan a keypad... :? :shock:
Exo is offline  
Old 9th February 2004, 03:28 AM   (permalink)
Default

The MAGIC of BASIC !
:lol:

Its only 415 without the LCD routines.....
csaba911 is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 05:50 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker