3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.


Kid's Game to Arduino Enigma Machine

Step 4

At this point it was apparent what pins on the cables coming out of the board were the columns and rows of the keyboard matrix. I used this keypad library http://www.arduino.cc/playground/Main/KeypadTutorial on my Arduino to control the keypad. In my case it was a 5x8 keypad, so I need 13 pins. I ended up using Digital pins 2 and 4-13 and Analog pins 0 and 1. I didn't use Digital pin 3 because I wanted that for driving the speaker in the game.

I kind of cheated when I mapped the key values. I basically just put bogus unique characters in the 2 dimensional array that defines the keys then I just started pushing buttons and had my Arduino output the keys pushed to serial. Then I could look at the output to set the 2 dimensional array for the library to the right values.

That seemed kind of confusing so I'll do an example. As part of the keypad library you define a 2 dimensional array so it knows what keys correspond to the values on the matrix. So basically it's something like this:

char keys[ROWS][COLS] = {
{'<','>','+',' ','5','4','3','2'},
{'^','*','%','#','6','1','Z','Y'},
{'X','W','V','U','T','S','R','Q'},
{'P','O','N','M','L','K','J','I'},
{'H','G','F','E','D','C','B','A'}
};

I'd then push a button on the keypad ('A' for example). Then I'd look at what came out on the serial console (say it was 'W', then I'd go and replace the 'W' in the matrix with an 'A'). After I went through all the keys then I had the keypad all mapped up.
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
8
Followers
5
Author:sketchsk3tch