Reading a button array with 3 analog pins (PCB design assistance)

I've seen this done before and to save pins on the wearable computer I decided to try it.

PCB design pros: Is anything wrong with this? Are my traces too noisy or too long? (You're looking at the green lines going to I/O pins 1, 2, and 3.)

Electrical engineers: Are the internal resistances of the buttons going to cause any issues when doing an analogRead() on them?

The extra mounting holes are for a rotary encoder and a joystick that I didn't feel like integrating into the PCB.

EDIT - I just realized how low-res this picture is. I/O pins 1, 2, and 3 are the top 3 pins on the I/O header. 3 is at the top, and it counts down to 1. Below that is GND and the bottom pin is VCC to power this board. The grey text above some mounting holes is there because of a settings error.

I wouldn't worry about the noise since you are almost at DC. But I am concerned with the buttons. First, what buttons are you using? All of the (inexpensive) square buttons I've seen connect diagonally. Also, it looks like you have traces going through the holes for the buttons.
button

I'm just using 6mm pushbuttons. They connect like this:
Push Button/Tactile Switch Pinout Connections, Uses, Dimensions & Datasheet

And yes, I have traces going through the THT holes because I want the buttons all connected in a row.

EDIT - I want everything hooked up like this but without one column:


...and then converted to this for analog "multiplexing":
image

No, the diagonal thing is for those who can't remember (and don't want to lookup or check) which pins are commoned!!

1 Like

I trace mine diagonally so that the orientation doesn't matter.

1 Like

That will depend on the quality of the buttons.

Since you do not anticipate detecting multipl button presses, why choose three analog inputs rather than one?

1 Like

I switched to Kailh Pro mechanical switches in the final design so I think that issue has been solved.

EDIT - As for the second thing, it's because someone already wrote code and there's less likelihood of error (IMO).

That's what the doubled pins are for, it's called feedthrough.

As you already have the code, why not just try it?

The Kailhs don't have those...

It costs me money (which I don't have much of) and JLCPCB shipping takes >2 weeks. We are moving soon so I have to wait until we are established to ship it.

That means that I have a lot of time to revise the board to make sure it works.

Why are the traces so thin ?

I’ll bet you have room for 35 to 50 mil traces.

They are just logic lines. Maybe I'll beef up the 5V and GND lines though.

Thicker traces are more robust, especially when it comes to people new to electronics/soldering.

True. I'll make them 0.4mm or something.

Why .4mm ?

Use 50mil and make the thru holes for the switches 80mil.

1 Like

BTW

If you used a $3.00 IR remote then all you need is one Arduino pin.

A laminated overlay with numbers can be attached to the top.

s-l400

Or a 44 button remote :astonished:

image

https://forum.arduino.cc/uploads/short-url/35Sd7MAryKhzZHuBtO96KO3NFxu.pdf

Fully aware. But I want my mechanical key switches and hacking those onto an IR remote sounds like a giant pain.

No, it is really simple.

Both remotes are NEC.

Remotes switches are snap action.

Use:
https://www.arduino.cc/reference/en/libraries/irremote/


//*****************************************************************************
//17 button Keypad
const byte buttonCode[18] = {
  0x46,0x44,0x40,
  0x43,0x15,0x00, //0X00 is not defined
  0x16,0x19,0x0D,
  0x0C,0x18,0x5E,
  0x08,0x1C,0x5A,
  0x42,0x52,0x4A
}; //END of buttonCode Array

const byte ASCIIcode[18] = {
  // ^    <   New line  
  0x5E,0x3C,0x0A,
  // >    v  nul 
  0x3E,0x76,0x00,
  // 1    2    3 
  0x31,0x32,0x33,
  // 4    5    6 
  0x34,0x35,0x36,
  // 7    8    9 
  0x37,0x38,0x39,
  // *    0    # 
  0x2A,0x30,0x23
}; //END of ASCIIcode Array