Starlight5
Posts: 24
Joined: Wed Apr 22, 2015 12:54 pm

Beginner wants to add membrane keypad buttons - please help!

Wed Nov 23, 2016 4:13 pm

Hello,

I would like to add a 4-key membrane keypad to my existing project, to control alsamixer volume.
Image

I would like 3 buttons to correspond to different alsamixer volume levels, and last button to be mute/unmute. I understand that I should use resistor(s). I read about examples which utilize breadboards and prototype pcbs but I need my setup to be very compact and fit inside the case like on photo, except for the button pad itself obviously - so those ain't an option.
Image

Now, my questions are:
How many resistors and in what configuration should I use?
How would you advise to connect me all this stuff to gpio? Can I just twist the wires together then cover them with electrical type, or is soldering still required for this application?

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Beginner wants to add membrane keypad buttons - please h

Wed Nov 23, 2016 4:27 pm

We use the resistors with projects for two purposes.

1: shortcircuit protection: If you accidentally set one of those Button GPIO pins as an output you could burn out the GPIO and start a cascade of damage that would eventually destroy the pi. To guard against that you need a current limiting resistor for each button (4 resistors).

2. Floating voltages: If the GPIO input is left floating the Pi won't know whether the switch is made or broken, the GPIO could float between the two states leading to false switching signals. To avoid floating voltages we use pull up or pull down resistors (Some GPIO pins have weak internal pull up or pull down resistors, whether these will be good enough for your circuit is not guaranteed). If needed another 4 resistors.

breadboard: solderless breadboards are quite bulky, soldered ones are much less so and could be hot-glued to the top of your case and connected to the GPIO by female dupont wires.
Doug.
Building Management Systems Engineer.

Starlight5
Posts: 24
Joined: Wed Apr 22, 2015 12:54 pm

Re: Beginner wants to add membrane keypad buttons - please h

Wed Nov 23, 2016 5:45 pm

@BMS Doug thank you!

So I understand that I need 4 restistors for short circuit protection - which exactly, 1.4K, 10K?..

Next, what should be the schematics with 4 button pad? My GPIO are currently all free, and I have no plans using them other for this button - so I assume I can get away without external pull-up resistors by utilizing correct pins. The guides I found are too complex for my understanding and leave out a lot, so I ask for someone to kindly provide a schematics and detailed explanation for this particular case.

User avatar
DougieLawson
Posts: 36540
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Beginner wants to add membrane keypad buttons - please h

Wed Nov 23, 2016 5:51 pm

Something around 600 ohms should be OK as a current limiting resistor.

You've got lots of GPIOs to choose from https://pinout.xyz pick a group of four that makes the wiring easy. I normally start with 17, 22, 27 & 23 as they're not already assigned to any other purpose (like 1-wire, I²C or SPI or serial) and they're available on my ancient old RPi1Bs.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Starlight5
Posts: 24
Joined: Wed Apr 22, 2015 12:54 pm

Re: Beginner wants to add membrane keypad buttons - please h

Wed Nov 23, 2016 7:07 pm

@DougieLawson thank you.

OK, I read some more and seems that I'll need pull-up resistors as well. If I decide to follow this example, but also want to add 1K resistors for short-circuit protection, where do I plug the 1K resistors?

Image

User avatar
DougieLawson
Posts: 36540
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Beginner wants to add membrane keypad buttons - please h

Wed Nov 23, 2016 9:08 pm

That works, it'll read a binary 1 (True, high) value until the switch is closed, then it will read binary 0 (False, Low). If you're connecting it to GND when the switch closes you don't need anything other than that 10K pull up resistor.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Beginner wants to add membrane keypad buttons - please h

Thu Nov 24, 2016 8:47 am

The Current limiting resistor would attach to the circuit where it says GPIO and the other end of the resistor would connect to the GPIO.

If you don't fit the current limiting resistor you won't damage the pi unless: you set the GPIO as an output and On AND you push the button.
Doug.
Building Management Systems Engineer.

Return to “Beginners”