7
votes

I'm pretty much a beginner with hands on electronics so I've decided to throw myself in at the shallow end with an arduino uno r3.

I've started a project and am happy dealing with leds, lcd displays and simple buttons but the project uses a home phone keypad that has 8 pins which, depending on the combination of pins bridged tells you which button has been pressed.

For example, if power is applied to pin 1 - if pin 5 has power then button 4 is pressed - if pin 6 has power then button 1 is pressed - if pin 7 has power then button 7 is pressed - if pin 8 has power then button * is pressed

My plan is to use 4 digital output pins and 4 digital (/ analog?) input pins. I'll set the first digital pin to high and check the value at each of the 4 inputs. Then move onto the second output and so on.

Am I going to blow some pins up on the arduino by connecting an output to an input? If not I'll continue.

Or, is there a better way?

Thanks in advance.

2
You might try this question at electronics.stackexchange.com. Stack Overflow is for programming questions.Greg Hewgill
This method of matrix_key_scanning was invented at least forty years ago: sweep on the Y lines and scan for correlated pulses on the X lines. Using 4 output lines and 4 input lines and a matrix of 16 cross-bar-switches is pretty common. It is still used on every keyboard in this side of the universe. (think: telephone)wildplasser
A safe approach when connecting to an external device is to add a series resistor from the output pins. If you place a 1 kOhm resistor between output and keypad, you would not be able to damage an output even if you shorted them all to ground.jdr5ca
Thanks for the comments. Apologies for posting here rather than at electronics.stackexchange.com, I simply found about 10 times as many results on searches for arduino here. OK, I may well end up adding a resistor close to the output pin just in case it does bridge to ground before it gets back to the input pin (which has it's internal own pull up resistor).Russell Keane

2 Answers

21
votes

You are fine. The Arduino input pins cannot damage its own output pins. Here is why:

All the numbers you need are in the "DC Characteristics" section of the chip data sheet, with 28.1 "Absolute Maximum Ratings" being what everyone should pay attention to.

Voltage

Any pin can be damaged if you put an excessively high or low voltage on it. From 28.1:

Voltage on any Pin -0.5 V to Vcc+0.5V

Because the Arduinos run at 5 V, that means -0.5 to 5.5 V is safe. Since the chip only has 5 V, there is no ability for it to damage itself by exceeding this limit. If you had a 9 V battery and connected that to one of the IO pins, then you would damage the pin.

Current

An output pin will be damaged if you draw too large a current. From 28.1:

DC Current per I/O Pin = 40.0 mA

One of your output pins will be connected straight to an input pin when you press a button. So the question becomes "how much current will an input pin draw?".

An ideal input pin consumes zero current. The arduino pins consume pretty close to zero. From section 28.2:

Input Leakage Current I/O Pin low = 1 uA

Input Leakage Current I/O Pin high = 1 uA

But, you may turn on the internal pull up resistors (strike may -- you are going to, correct?). Those are in the same section:

I/O Pin Pull-up Resistor 20 - 50 kOhm

These pull up resistors contained in the input pin are the main load. So a logic 0 output will be loaded to 0.25 mA (=5 V / 20 kohm). A logic 1 output will be loaded 0 mA. In other words, completely safe.

So you see now, you are very much within the safe operating area. These specifications for current and voltage are the first items you want to understand before connecting things together.

0
votes

You should use a really low voltage, low current, and a lot of caution when you're doing this. You may be able to download documentation on the specific stuff you're using, which eliminates the need to trial-and-error.

I have done stuff like this myself, although not with the particular chip you're using, and I haven't destroyed anything yet. All the same, proceed with extreme caution.