12 button keypad from spark fun

08653-03-L_i_ma.jpg

Keypad_1-0.zip (9984Bytes)

Hi, got this keypad from my local sparkfun distribuitor, but wasn't sure how to wire it up, the pins aren't in order, like on most other tutorials/examples, so here's how to have it up nd running in no time!

just wire it like this:

I know about the ''arudino'' mistake, sorry, typo :(
And run this code:
/* @file HelloKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact [email protected]
||
|| @description
|| | Demonstrates the simplest use of the matrix Keypad library.
|| #
*/
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'#','0','*'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
Serial.begin(9600);
}
void loop(){
char key = keypad.getKey();
if (key != NO_KEY){
Serial.println(key);
}
}
be sure to have the keypad library installed, it's attached to this post.
For more details, go here:
http://www.instructables.com/id/Using-the-sparkfun-12-Button-keypad-with-the-ardu/

 

I’ve got one of these lying

I’ve got one of these lying around.

Any instryctions on how to wire it up to a picaxe? 28X1?

Cool, you could also submit
Cool, you could also submit the pad itself as a component - and from there link to this nice tutorial. That might help a lot of people :slight_smile:

The wiring should the same,
The wiring should the same i guess but the code will be different, I dont know anything about picaxe unfortunately :frowning:

Re: libraries

The “keypad.h” library is open source and pretty straightforward (if you’ve read up on the theory of operation for keypads). If you read C/C++/Arduino C it is at
http://www.arduino.cc/playground/Code/Keypad
and also attached to the post.

Not sure about an analogue on the PIC side of things. The library is less than 150 lines of code (in keypad.h and keypad.cpp). It would probably take up to 20 hours to translate and test it on the PIC if it doesn’t already exist.

my 2¢,
-John

I have used following code,

I have used following code, and it did work:

symbol pressed = b0
symbol i = b1
symbol keyr = b2
symbol keyc = b3
symbol gotkey = b4
symbol char = b5
symbol addr = b6
symbol j = b7

symbol keystring = 0

’--------------

gosub allhigh
put keystring, “1”,“2”,“3”,“4”,“5”,“6”,“7”,“8”,“9”,"*",“0”,"#"

main:


pressed = pins & %00001111 'retrieve only bits we interested in
if pressed > 0 then 'looks like we have key pressed
'pause 1 'pause 20 us
gosub readkey
'--------------------------------------------------------------------------
'Here you will have key pressed in char. it will be zero if nothing pressed
endif

goto main


’SUBROUTINES

allhigh:

high 1
high 2
high 3

return

alllow:

low 1
low 2
low 3

return

readkey:
'now lets scan which row we have pressed key in
gotkey = 0
for i = 1 to 3
gosub alllow
high i
pressed = pins & %00001111
if pressed > 0 then
for j = 0 to 3
pressed = pressed >> 1
if pressed = 0 then
exit
endif
next j
keyr = j

keyc = outpins & %00001110
keyc = keyc >> 1
for j = 0 to 2
keyc = keyc >> 1
if keyc = 0 then
exit
endif
next j
keyc = j

debug keyc
debug keyr

gotkey = 1
exit
endif
next i
if gotkey = 1 then
'now check what we have here and show on screen
addr = keyr * 3 + keyc
get addr, char
else
char = 0
endif
gotkey = 0
gosub allhigh
return

What could you use this for?
I’m just curious and would like to know how you could implement this keypad into robot building and what function(s) wuld be practical?

I suppose you could have

I suppose you could have different functions for your robot, and give each function a number, when you press your function of choice, it starts doing it…?

I’m using mine for a timer for my insulator :slight_smile:

 

EDIT: or in case you have some algorithm like adaptive mapping, you could use the pad to enter some sort of coordinates?