Today there's a plethore of choices of buttons and tactile switches at any price and any form factor. Unfortunately, if you're looking to get analog input, your options are more limited. If a capacitive slider is not meeting your need, you're probably out of luck.
I set out to build a musical instrument that could detect how hard the user pressed the buttons, continuously. Piezzoelectric sensors were out of the question, because while they can give readings on how hard you press, it's difficult to keep these readings accurate for multiple seconds. Flex sensors were expensive and unwieldy.
Velostat, which is a brand of piezzo-resistive plastic (the more you press, the lower its electrical resistance) fit the bill perfectly. Today, I'll walk you through a proof-of-concept, and a nice prototype. The latter actually works quite reliably after calibration, and is simple and cheap enough that you might consider making them by the dozen.
Step 1: Step 1: Proof-of-concept
Using a piece of cardboard and a conductive ink pen, draw an interwinded comb pattern. My tracks are about 2mm wide and 1mm across. I then cut a 15*15mm piece of velostat that I put on top.
When pressing with my finger, I can measure a resistance between 5 and 15 kOhm, depending on how hard I press.
Step 2: Step 2: the PCB
I designed a PCB circuit for my project and had it professionally produced. On this examples, the tracks are 0.5mm wide and 0.5mm apart; but Velostat is actually quite forgiving.
To get good results, put Velostat only where you need it. I punched 5mm-dimeter pieces, and taped them with regular tape. Z-axis conductive tape does not work here, as it releases very slowly, and you cannot tell when the user has lifted his finger.
Step 3: Step 3: the Button Cap
I used silicon buttons I ordered from Taobao (but if you don't live in China, you might have better luck on you usual electronics shop). They are 10mm in diameter, (12 at the base), and don't have a conductive pad underside.
The base is about 1mm thick, which is close to the thickness of double-sided tape I had lying around.
To punch a hole in the double-sided tape, you need to lay it flat; to keep it from sticking on your desk, use a piece of silicone-coated paper, like the protective film of your roll of double-sided tape, and stick it underside. I found my punches on Taobao, for less than a dollar a piece.
On top of the double-sided tape, I put a piece of plastic from the cover of a used notepad.
Step 4: Step 4: Use It!
After assembling the button, I put my finger on top, and measured resistances of 1.5 to 18 kOhm. If you lift your finger, the Velostat might touch or not, so the cicuit is sometimes open.
To use this new button, setup a voltage divider bridge with a resistor (say, 4kOhm). The middle point can be measured with an Arduino.
You then need to measure the values for minimum and maximum pressure, and calculate how far you stand between the two. I have been able to get 7- or 8-bit responses out of a 10-bit Atmega analog input without too much fiddling.
The response curve is not linear. I have not tried to normalize it yet. Also, there is some hysteresis: the value you return to after releasing the button is often slightly different from the one you had just before pressing. However, when using it with a human finger, it's already good enough for pitch bends and vibratos.