Phone Keypad Hacking: Part 3

In parts 1 and 2, I walked through my journey of repurposing the keypad out of a phone from 1980. I learned that a more modern keypad matrix doesn’t exactly function (behind the scenes) in a way I’d expect. I wanted to understand it better so I set out to recreate a 2×2 keypad (kept it simple to make wiring easier) that would function the same way as something you can buy today. It would be a success if it worked with the Arduino Keypad Library.

adafruit-3x4-keypad

From my earlier looks through the code I knew it pulsed power out to a column pin and then read in each row’s key from that column before switching to the next column and repeating the process. I figured that should be enough for me to wire this up and try example programs without going back to look at the library’s code again.

I don’t know why I was thinking this would be more complicated and at least a little more exciting, but it was unbelievably easy. I guess I should be celebrating I understood how it worked. Literally all you do is connect one side of every button in a column to a pin and one side of every button in a row to a pin. No need for connections to power, or ground. No pull up/down resistors.

2x2-keypad-matrix-wiring.png

It immediately worked with the Arduino Keypad library examples, even the MultiKey one. I guess being able to detect multiple key presses at once is where the advantage to this implementation comes in. It worked flawlessly when pressing 2 of the 4 buttons, but when you get to 3/4 there are too many connections to distinguish the keys.

Just to be sure I had it figured out, I added a 3rd column to make it a 2×3 grid and it was just as easy.

2x3-keypad-matrix-wiring.png

I love the beauty of how simple this is. I’ve added Fritzing for both of these to my phone-keypad GitHub repo (2×2 & 2×3). If you check this PDF, in the How it Works section it has a really good explanation and shows the row and column connections exactly like I came up with.

Naturally now I need to do a part 4 and attempt to recreate the keypad implementation I ended up with from the old phone. Due to how it mechanically makes the electrical connections I think it’s going to be a bit more complicated than this was. We shall see…

Update: Read part 4.

The OA…The End

I’d been limiting myself to no more than one episode of The OA per night, which has allowed me to enjoy each episode more I think. Last night I was watching episode 8 and then all of a sudden, season 1 is over. What the fuck just happened?!

I hadn’t looked at the episode list, but was fully expecting 5 more episodes, which is typical for a lot of Netflix shows. Even towards the end of #8 I didn’t expect the end was coming. So much shit happened in that episode and now I have so many questions.

I’m hoping there was already a good plan for season 2 because the sudden end completely threw me off guard and it feels like a rush job.

Link Dump – 2017/05/09

I’m going to try something different with these link dumps. I’ll write a little about each link. Might be a sentence or it might be a paragraph.

Phone Keypad Hacking: Part 2

Go back and read Part 1 if you want to the full story on this little project. I did decide to get rid of the PCB on the old phone keypad. Good thing I’ve been getting a lot of desoldering practice. In order to remove the PCB, I first had to remove the wires I had added to the column and row contact points. That was easy and getting the PCB off was a pretty smooth process as well.

PCB and new look of the back side of the keypad.
Other side of the PCB. The white rectangle is the back of the 557D IC.

Now that I didn’t have the PCB to carry power and ground around everywhere, I had to solder in my own wires. I also had to solder back in all of my connection points to provide the outputs I’d feed into a microcontroller (I used an Adafruit Feather 32u4 Basic Proto).

Once all of the wires were in place and then connected to my microcontroller I wasn’t getting expected results from a simple little program I wrote to display the values. Took far too long for me to remember I needed to use pull down resistors to prevent floating values. I put 10k Ω resistors in each of the circuits…

img_8994
Prototyping with pull down resistors.

Output from the pins couldn’t get any better…

phone-keypad-row-col-values.png

I loaded an example from the Arduino KeyPad library, which gave me very weird behavior. After looking at the underlying code, I realized it wanted the outputs of the keypad to be HIGH when a key was not pressed and LOW when it was. Well, my circuit was doing the opposite, so I had to have to invert everything. I didn’t have any inverter ICs, so I used NPN transistors to create an inverter circuit on each output.

img_8993
Prototyping by inverting the output of the keypad column and row values.

Progress. Now I was able to get the library to correctly recognize some key presses. 95% of the time it seemed to think everything was coming from column 1 (1, 4, 7, *) though. The library comes with a MultiKey example. When I ran that, it was reporting every key on the row as being pressed. WTF?!

For the life of me I could not figure out what caused this. I checked wires, measured voltages, did continuity tests, resoldered connections, changed boards, used different GPIO pins, and countless other things. Nothing made a difference. My own code was working beautifully though. Eventually I gave up on the library. It wasn’t worth the effort and I was out of ideas.

Update: Later on I went back and read the KeyPad library code again because it was bugging me. Turns out these keypads don’t actively read the column pins like they do the row pins. My assumptions about how they worked was very wrong because I hadn’t read far enough into the code before. When checking for key presses, typical keypads iterate through the columns to send a pulse which feeds over in to the rows, which are then read in. How a Key Matrix Works has a pretty good explanation with visuals. If I get my hands on another similar keypad maybe I’ll try to recreate this functionality.

I rewired everything to use the pull down resistors again (video of soldering). A huge benefit of the decision was it drastically simplified my circuitry. This would save me 49 solder points! I probably would have needed to use a half-size perma-proto board instead of the 1/4 size I ended up using.

I decided to put in a piezo buzzer to add sounds. I also used a tiny LED, which I had salvaged from some old computer speakers, to show when power is switched on to the backlight.

The finished board. Isn’t it a thing of beauty?

 

Side view before bending the output wires off to the sides.

I tried a couple of different methods of producing touch tones (DTMF) to match up with each key, but with the microcontroller I’m using and the small piezo buzzer, the sound was terrible. I would need something a little more capable I think.

Here’s a demo video.

Hard to see the OLED screen in the video, but I was only using it to output each key press. Something like this…

phone-keypad-oled-output.jpg

All of the code and Fritzing wiring are available in my phone-keypad repo on GitHub.

I even went out of my comfort zone and did a quick share of this on Adafruit’s Show and Tell. If the video doesn’t start at the right spot you can skip ahead to the 12:42 mark. Going back to watch, my demo kind of sucked since it’s hard to hold something up to the Mac camera and push buttons at the same time.

Update: Continue on to Part 3, where I create a matrix of buttons to act as a keypad.

Yellowbook

A couple of weeks ago I came home to find this 2017/2018 Yellowbook thrown in my driveway. How is a physical phone book still a thing?

Remember the white pages where you could look up the phone number for anyone in your area? Seems like decades ago, though I couldn’t tell you the last time I called a personal land line.