> ... 1. Once you have programmed the chip can you fairly easily pull
it off the development board and plug it onto a breadboard for its final
application ?
Sure. It's usually just as easy to put a serial port connector (a DB9
or a four-pin header, usually) on your final project breadboard so you
can program and operate the processor in place but, if you wish, you can
program the processor module on one board and run the code on another.
> ... 2. Can you use this chip to accept data from a standard 4*4 keypad...
Yes, certainly. A 4x4 matrix keypad can be directly connected to eight
I/O pins. The following code if taken from the LCDX function library
(in Files).
Tom
'-------------------------------------------------------------------------------
Public Function GetKeypadRaw() As Byte
' This program will read a 4 x 4 matrix keypad connected to the PORTC
pins and return its Raw data.
' Keypad port shares I/O pins with LCD display so it must be returned as
we found it. 255 = no key
' On return, PORTC is configured to input-pullup.
Dim Vertical As Byte
Dim Horizontal As Byte
' Set PortC high
Register.DDRC = bx1111_1111
Register.PORTC = bx1111_1111
' Set up PORTC for a horizontal scan:
' Set bits C0 .. C3 (LSNybble) to input-pullup -- horizontal.
' Set bits C4 .. C7 (MSNybble) to output-low -- vertical.
Register.DDRC = bx1111_0000
Register.PORTC = bx0000_1111
' LSNybble
Horizontal = Register.PINC And bx0000_1111
' Set PortC high
Register.DDRC = bx1111_1111
Register.PORTC = bx1111_1111
' Set up PORTC for a vertical scan:
' Set bits C0 .. C3 (LSNybble) to output-low -- horizontal.
' Set bits C4 .. C7 (MSNybble) to input-pullup -- vertical.
Register.DDRC = bx0000_1111
Register.PORTC = bx1111_0000
' MSNybble.
Vertical = Register.PINC And bx1111_0000
' Combine horizontal and vertical nybbles.
GetKeypadRaw = Vertical Or Horizontal
' Turn on PortC Pull-ups
Register.DDRC = bx0000_0000
Register.PORTC = bx1111_1111
End Function
'-------------------------------------------------------------------------------
Public Function GetKeypad() As Byte
' This sub will read the NetMedia 4 x 4 matrix keypad connected to the
PORTC pins
' and return the keys values as displayed on the keypad. Values are 0-9
and 10 - 15, 255 = no key.
' Keypad port shares I/O pins with LCD display so it must be returned as
we found it.
' On return, PORTC is configured to input-pullup.
Dim Vertical As Byte
Dim Horizontal As Byte
Dim Raw_Key As Byte
' Set PortC high
Register.DDRC = bx1111_1111
Register.PORTC = bx1111_1111
' Set up PORTC for a horizontal scan:
' Set bits C0 .. C3 (LSNybble) to input-pullup -- horizontal.
' Set bits C4 .. C7 (MSNybble) to output-low -- vertical.
Register.DDRC = bx1111_0000
Register.PORTC = bx0000_1111
' LSNybble
Horizontal = Register.PINC And bx0000_1111
' Set PortC high
Register.DDRC = bx1111_1111
Register.PORTC = bx1111_1111
' Set up PORTC for a vertical scan:
' Set bits C0 .. C3 (LSNybble) to output-low -- horizontal.
' Set bits C4 .. C7 (MSNybble) to input-pullup -- vertical.
Register.DDRC = bx0000_1111
Register.PORTC = bx1111_0000
' MSNybble.
Vertical = Register.PINC And bx1111_0000
' Combine horizontal and vertical nybbles.
Raw_Key = Vertical Or Horizontal
' Turn on PortC Pull-ups
Register.DDRC = bx0000_0000
Register.PORTC = bx1111_1111
' If no key is pressed return 255 and exit function
If Raw_Key = 255 Then
GetKeypad = Raw_Key
Exit Function
End If
' Map the raw keypad data to the NetMedia Keypad keys
Select Case Raw_Key
' For digits 0 - 9
Case 126
Raw_Key = 1
Case 125
Raw_Key = 2
Case 123
Raw_Key = 3
Case 190
Raw_Key = 4
Case 189
Raw_Key = 5
Case 187
Raw_Key = 6
Case 222
Raw_Key = 7
Case 221
Raw_Key = 8
Case 219
Raw_Key = 9
Case 237
Raw_Key = 0
' For other keypad keys
Case 119
Raw_Key = 10 ' Up Arrow
Case 183
Raw_Key = 11 ' Down Arrow
Case 215
Raw_Key = 12 ' "2nd" Key
Case 238
Raw_Key = 13 ' Clear Key
Case 235
Raw_Key = 14 ' Help Key
Case 231
Raw_Key = 15 ' Enter Key
' Bad keypad read will return 255
Case Else
Raw_Key = 255
End Select
GetKeypad = Raw_Key
End Function
'-------------------------------------------------------------------------------