Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

From Rosy to Nigel Goodwin

Status
Not open for further replies.

Rosy

New Member
I am using a PICBasic Pro that depends on dealing with the keypad switches as a matrix the program is as follows:
' PicBasic Pro program to display key number on LCD
' Define LCD connections
INCLUDE "modedefs.bas"
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 1
' Define program variables
col VAR BYTE ' Keypad column
row VAR BYTE ' Keypad row
key VAR BYTE ' Key value
st VAR BYTE 'key status
OPTION_REG.7 = 0 ' Enable PORTB pullups
ADCON1 = 7 ' Make PORTA and PORTE digital
Low PORTE.2 ' LCD R/W low (write)
Pause 100 ' Wait for LCD to start
LCDOut $fe, 1, "Press any key" ' Display sign on message
loop: GoSub getkey ' Get a key from the keypad
LCDOut $fe, 1, #key ' Display ASCII key number
GoTo loop ' Do it forever
' Subroutine to get a key from keypad
getkey:
Pause 50 ' Debounce
getkeyu:
' Wait for all keys up
PORTB = 0 ' All output pins low
TRISB = $f0 ' Bottom 4 pins out, top 4 pins in
IF ((PORTB >> 4) != $f) Then getkeyu ' If any keys down, loop
Pause 50 ' Debounce
getkeyp:
' Wait for keypress
For col = 0 to 3 ' 4 columns in keypad
PORTB = 0 ' All output pins low
TRISB = (DCD col) ^ $ff ' Set one column pin to output
row = PORTB >> 4 ' Read row
IF row != $f Then gotkey ' If any keydown, exit
Next col
GoTo getkeyp ' No keys down, go look again
gotkey: ' Change row and column to key number 1 - 16
key = (col * 4) + (NCD (row ^ $f))
SerOut PORTC.6,T2400,["S",#key," ON" ]
LCDOut $fe, 1 ' Clear screen
Return ' Subroutine over
End
************************************************************
So I don't want to use this code, I need a code that deal with each switch separatly than the other as if they are connected serially.....The location of the switches will remail displayed until the switches released....
I hope that I'll get benifit from u...
Thanx a lot
 
Rosy said:
So I don't want to use this code, I need a code that deal with each switch separatly than the other as if they are connected serially.....The location of the switches will remail displayed until the switches released....
I hope that I'll get benifit from u...
Thanx a lot

Sorry, I don't use PICBasic, and I don't know what you mean by 'connected serially'.
 
If you want to post to someone directly, use the private message service...

You should try asking ivancho for this, he's got more expierience using picbasic
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top