Yes, a simple keypad like the one you indicate can be used in a number of ways.
Could you explain this further? Not sure what strobe means.If you have enough I/O lines available on the PICAXE chip, then just strobe a column/row and then read the inverse (Ie row or column).
'Michael Eaton 2010
'Matrix keypad to 7 segment display.
'The program reads inputs from a 3x4 keypad and displays them on a 3 digit display.
'Pressing '*' clears the display, entering numbers makes them appear from right to
' left on the display. Entering more than 3 digits without clearing first will not
' change the display (ie subsequent numbers are ignored).
#Picaxe28X1
'Connections:
'Picaxe Pins Keypad Pins 7 Segment pins
'C0 2 (column 2)
'C1 3 (row 1)
'C2 4 (column 1)
'C3 5 (row 4)
'C4 6 (column 3)
'C5 7 (row 3)
'C6 8 (row 2)
'0 Reset (14)
'1 Clock (16)
'2 Latch (15)
'3 Output Enable (13)
'4 Data (11)
' GND (1,2,3,4)
' 12V (5,6,7,8)
' Vcc (9,10)
symbol columnOutputs = %00010101 'Define keypad columns
symbol rowOutputs = %01101010 'Define keypad rows
symbol outNumber = b0 'variable for output number
symbol shiftCounter = b1 'output counter to send display data serially
symbol columnInput = b2 'column storage for keypad input
symbol digit1 = b3 'Rightmost digit
symbol digit2 = b4 'Middle digit
symbol digit3 = b5 'Leftmost digit
symbol digitCount = b6 'used to keep track of which digit is active
symbol number = b7 'variable used to read in bits and also to store the number. Used for lots of things
let shiftCounter = 0 'Initialise all variables to zero
let columnInput = 0
let digit1 = 0
let digit2 = 0
let digit3 = 0
let digitCount = 0
let number = 0
'pin assignments
symbol shiftRegReset = 0 'leg 21
symbol dataClock = 1 'leg 22
symbol latch = 2 'leg 23
symbol outputEnable = 3 'leg 24
symbol serialData = pin4 'leg 25
high shiftRegReset
low outputEnable
main:
gosub inputNumber
if number = "*" then 'clear display when * is pressed
let digitCount = 0 'reset digit counter to allow a new number to display
else
if digitCount = 0 then 'put number into Rightmost digit and clear middle and leftmost digits
digit1 = number
digit2 = 0
digit3 = 0
elseif digitCount = 1 then 'put new number into middle digit, leaving rightmost and clearing leftmost
digit2 = number
digit3 = 0
elseif digitCount = 2 then 'leave middle and rightmost, put number into leftmost digit
digit3 = number
else goto main 'and don't output any more numbers
endif
endif
high outputEnable 'blank display
gosub sendData
low outputEnable 'turn on the display
pause 300
goto main
end
'*****************************************************
' Subroutines
'*****************************************************
inputNumber: 'first turn columns to outputs and monitor the rows
let dirsc = columnOutputs
let pinsc = columnOutputs
inputLoop: 'then check for a button press
readportc number 'store the pins so we can work out which row was activated
let number = number & rowOutputs 'mask to only see the row input pins
if number <> 0 then 'if the port changes (does not equal what we set it to)
let dirsc = rowOutputs 'transpose the inputs/outputs on portc
let pinsc = rowOutputs
readportc columnInput 'store the pins again so we can work out which column was activated
let columnInput = columnInput & columnOutputs 'mask to only see the column input pins
else goto inputLoop
endif
let number = number or columnInput 'combine both variables to allow easier lookup
select case number 'lookup table
case %00000110 'row 1 column 1
let number = %00001100 '1
case %00000011 'row 1 column 2
let number = %10110110 '2
case %00010010 'row 1 column 3
let number = %10011110 '3
case %01000100 'row 2 column 1
let number = %11001100 '4
case %01000001 'row 2 column 2
let number = %11011010 '5
case %01010000 'row 2 column 3
let number = %11111010 '6
case %00100100 'row 3 column 1
let number = %00001110 '7
case %00100001 'row 3 column 2
let number = %11111110 '8
case %00110000 'row 3 column 3
let number = %11011110 '9
case %00001100 'row 4 column 1
let number = "*" 'star
case %00001001 'row 4 column 2
let number = %01111110 '0
case %00011000 'row 4 column 3
let number = %10000000 '-
else
let number = %00000000 'blank
end select
return
end
'*****************************************************
sendData:
inc digitCount
let outNumber = digit1 'output all of the digits in sequence, starting with rightmost
gosub sendBits
let outNumber = digit2
gosub sendBits
let outNumber = digit3
gosub sendBits
pulsout latch,1 'latch data
return
end
'*****************************************************
sendBits:
'This section of code sets the serial data pin to bit0 and then sends
' a clock pulse. Bit1 is then shifted to bit0, another clock pulse follows
' and this continues until the whole byte has been sent. A latch pulse
' is then sent and the number will be displayed.
for shiftCounter = 0 to 7
serialData = bit0 'serial data
pulsout dataClock,1 'serial clock pulse for 1 millisecond
outNumber=outNumber/2 'shift bits along to output the next bit
next shiftCounter 'loop 8 times to output the whole byte
return
end
'*****************************************************
Thanks for the link. People have spoken about this solution but I hadn't seen it. Cheers, I like it.fellow kiwi stan swan and andrew hornblow have solved this problem using readadc!
http://picasaweb.google.com/picaxe/Data#5135513215478423634
'Michael Eaton 2010
'Resistor matrix keypad to 7 segment display.
'The program reads analogue voltage from a 3x4 keypad and displays the numbers on a 3 digit serial display.
'Pressing '*' clears the display, entering numbers makes them appear from right to
' left on the display. Entering more than 3 digits without first clearing will not
' change the display (ie subsequent numbers are ignored).
#Picaxe20M
'Connections:
'Picaxe Pins Keypad Pins 7 Segment pins
'ADC1 5
'0 Data (11)
'1 Output Enable (13)
'2 Latch (15)
'3 Clock (16)
'4 Reset (14)
' GND (1,2,3,4)
' 12V (5,6,7,8)
' Vcc (9,10)
'Input Pin Assignments
symbol InputPin = 1 'ADC pin for keypad input leg 9
'Output Pin Assignments
symbol serialData = pin0 'leg 18
symbol outputEnable = 1 'leg 17
symbol latch = 2 'leg 16
symbol dataClock = 3 'leg 15
symbol shiftRegReset = 4 'leg 14
'Initialise Output Pins
high shiftRegReset
high outputEnable
symbol outNumber = b0 'variable for output number
symbol shiftCounter = b1 'output counter to send display data serially
symbol digit1 = b3 'Rightmost digit
symbol digit2 = b4 'Middle digit
symbol digit3 = b5 'Leftmost digit
symbol digitCount = b6 'used to keep track of which digit is active
symbol number = b7 'variable used to read in bits and also to store the number. Used for lots of things
let shiftCounter = 0 'Initialise all variables to zero
let digit1 = 8
let digit2 = 8
let digit3 = 8
let digitCount = 2
let number = 8
'Main Program Loop
main:
gosub inputLoop
if number = "*" then 'clear display when * is pressed
digitCount = 0 'reset digit counter to allow a new number to display
digit1 = 0
digit2 = 0 'clear all 3 digits
digit3 = 0
else
if digitCount = 0 then 'put number into Rightmost digit and clear middle and leftmost digits
digit3 = 0
digit2 = 0
digit1 = number
elseif digitCount = 1 then 'put new number into rightmost digit, move rightmost to middle and clear leftmost
digit3 = 0
digit2 = digit1
digit1 = number
elseif digitCount = 2 then 'shift middle and rightmost left one digit, put number into rightmost digit
digit3 = digit2
digit2 = digit1
digit1 = number
else goto main 'and don't store any more numbers
endif
inc digitCount
endif
high outputEnable 'blank display
gosub sendData 'send data to display
low outputEnable 'turn on the display
pause 300
goto main
end
'*****************************************************
' Subroutines
'*****************************************************
inputLoop: 'check for a button press
pause 1
readadc InputPin, number
if number < 15 then
goto inputLoop
elseif number < 58 then let number = %00001100 '1
elseif number < 63 then let number = %10110110 '2
elseif number < 67 then let number = %10011110 '3
elseif number < 74 then let number = %11001100 '4
elseif number < 80 then let number = %11011010 '5
elseif number < 88 then let number = %11111010 '6
elseif number < 100 then let number = %00001110 '7
elseif number < 115 then let number = %11111110 '8
elseif number < 135 then let number = %11011110 '9
elseif number < 175 then let number = "*" 'star
elseif number < 210 then let number = %01111110 '0
elseif number > 209 then let number = %10000000 '-
endif
return
end
'*****************************************************
sendData:
let outNumber = digit1 'output all of the digits in sequence, starting with rightmost
gosub sendBits
let outNumber = digit2
gosub sendBits
let outNumber = digit3
gosub sendBits
pulsout latch,1 'latch data
return
end
'*****************************************************
sendBits:
'This section of code sets the serial data pin to bit0 and then sends
' a clock pulse. Bit1 is then shifted to bit0, another clock pulse follows
' and this continues until the whole byte has been sent. A latch pulse
' is then sent and the number will be displayed.
for shiftCounter = 0 to 7
serialData = bit0 'serial data
pulsout dataClock,1 'serial clock pulse for 1 millisecond
outNumber=outNumber/2 'shift bits along to output the next bit
next shiftCounter 'loop 8 times to output the whole byte
return
end
'*****************************************************
end
I've been working on that too! I'm trying to get a bigger spread at the lower end of the scale to reduce possible read errors. I haven't been able to improve it though.I made up a spreadsheet