12 switch keypad - Am I doing it Right?

Hi there. Please forgive me if I chose the wrong forum.

I have been playing around with Arduino sensors and -programming for a while now, but I wanted to learn the very basics of electronics.

I recently bought this 12 switch keypad. The challenge to making the keypad work is that there are fewer pins than there are keys. I know you can connect different resistors and have the Arduino calculate which button you clicked, but I wanted to do it without the help of a microcontroller, so I connected some transistors and made the design below. I hope the description makes sense. As an electronics beginner and non-native English speaker it's difficult to find the precise terms.

Challenge: Two switch keys are sharing the same output pin.
Solution: Checking which pin is the active input pin.

I know it works as I've tested it on a breadboard, but I'd love some general feedback from more experienced people.

  • Does the design make sense? It it too complicated?
  • Resistors: Should I add one before every transistor and LED? How do I know when and where to add resistors? I know how to use Ohm's law to control the current entering an LED, but should I use resistors if the circuit already causes a relatively significant voltage drop?
  • Anything else I should know?

Key pads are normally connected in columns and rows. Post a link to the keypad you have and we may be able to tell you how it is wired. It will be something like pressing key x shorts with 3 and 4. Pressing y shorts 2 and 4 and so on.

The keypad is wired as such:

I'm currently testing out keys 3 and 6 with pin 1 and 2 as input, and pin 7 as output.

There is an Arduino library that will decode that for you... So why did you want to use several transistors when someone has put 100,000 in a package for you to use as you wish.

Coding the Arduino is great for many things, but it doesn't teach me the fundamental electronic processes of ICs.

Well, you can learn how simple ICs work, but how an old keyboard encoder worked is frankly wasteful and huge.

Upstairs I have an old keyboard which used to connect to a tape encoder. It had a hard wired and soldered lead into a bunch of cards that was around 2 inches thick. Each switch had its own pair of wires.

These days you would use a keyboard encoder which strobes rows and reads outputs on columns. It's a lot smaller and needs a lot less wires.

This is not a good place to understand the transistor to transistor logic built into ICs. If you want to do that, why not start with making logic gates from transistors? You can even make RAM with them You may end up using a few though.

I'm not doing this to make anything or find a practical way to use a keypad. I'm only doing it to try and understand how these things work. And it does seem to work, but I'd like some feedback on whether the circuit has some flaws that I'm not seeing. Outside of being impractical in these days of microchips.

Building logic gates is relevant for learning too, and I have been playing around with that as well. But it's not what I'm doing here.... Although I did try to use an AND gate (if input A and output B then LED C on), but couldn't make it work.

OK, all you want for this is a "mirror" which is quite easy to do. You will need seven transistors and seven resistors. Your 10 ohm resistor is clearly wrong - should be 470 at least.

OK, for each column, you need a PNP resistor with its emitter connected to the supply voltage, its base connected to the column line on the keyboard via a 10k resistor and its collector connected to the column anodes of your matching LED array via a 470 ohm resistor.

Similarly, each row connects to the base of an NPN transistor whose collector correspondingly goes to the cathode row of your LED matrix. It emitter of course goes to ground. Note that there is always a resistor between the base of a PNP transistor through the keypad to the base of the NPN transistor, and there is always a resistor between the collector of a PNP transistor through a LED to the collector of an NPN transistor.

Pressing a key simultaneously switches a PNP and NPN transistor to apply power to the corresponding LED. And yes, you can control 12 LEDs remotely with seven wires as long as you do not simultaneously press buttons on different rows and different columns.

I don't really understand why so many transistors. Nevertheless, it's a good idea to get a good understanding of analog electronics, rather than relying on ICs to do everything for you.

Rather than messing around with switch pads though, I'd suggest you start playing with oscillator circuits. Just by mastering the modest demands of a simple oscillator, you'll be able to create a tone that can be heard on some headphones. You'll then be able to build a second oscillator with a much slower frequency to control the output of your tone generator so that it pulses, like a beeper. This is called modulation. Then you can build another oscillator that operates at radio frequencies. Use your first oscillator to modulate this one and you have a beep that you can send over the airwaves.

Without much alteration you could then add a microphone to send audio. A slight more modification and you'll be able to send data.

By the time you get this far, you'll likely start getting interested in video. Checking out the standards for composite video you'll notice that there's a space in the flyback cycle just begging to be filled with data bytes. So naturally you'll come up with a scheme to build a device that will embed data into this space before sending the altered signal wirelessly to a reciever. Naturally your reciever will be able to separate the data to make it available to another arduino.

Once you've perfected these shields, give me a call, I want some :slight_smile:

A 12-key keypad was designed to be used with columns and rows. To attempt to use it any other way is absurd and a waste of time because it makes no sense.
Ditto the "10 ohms is clearly wrong. It should be 470 at least".

You're going to damage the base of those npn transistors with such a low base resistance.
Read the datasheet.
There is a special HELL reserved for people who don't read datasheets:
It is a place where nothing works and everything smokes on powerup.

KenF:
Checking out the standards for composite video you'll notice that there's a space in the flyback cycle just begging to be filled with data bytes. So naturally you'll come up with a scheme to build a device that will embed data into this space before sending the altered signal wirelessly to a receiver. Naturally your receiver will be able to separate the data to make it available to another Arduino.

You are of course, referring to the forty year old Teletext, aren't you?

Paul__B:
You are of course, referring to the forty year old Teletext, aren't you?

Exactly!. So proof of concept isn't even required. We just need to bundle it onto an arduino shield.