# Applying PWM to get analog button

I am trying to understand how to turn a basic click button into something that behaves like a pressure sensitive button, meaning the harder you press it the greater the value.

There are PWM modules that you can use to get different current but I am thinking of something like a button.

Could I do this with a micro-controller, a click button and some software or are there special buttons that do the job and send signals in a range based on how hard/ fast it's pressed?

I would go for a so called series elastic element (SEE). Just make a small guide and slider, attach a compression spring to one end of the guide and to the slider and measure the position of the slider by using a linear potentiometer (super easy to read out with an Arduino, you basically just need GND, 5V and an analog input). If you push the slider, the spring generates force and you can read it out by getting the position of the lin pot.

The problem with force gauges most often is that they move only for some micrometers. If you implement a SEE you will combine force and position, making it much easier to use your button (better control for us stupid humans). Furthermore, you have a linear relationship between force and position $F = - k \cdot (x_o - x)$, as well as between position and signal provide by the lin pot. --> Easy calibration

Good luck :)

• Wow, this lead me down a rabbit hole for future ideas but I do think SEE is the better option for my project. Thanks for the additional insight! Nov 24, 2017 at 4:43

A standard on/off push button will not read analog.

To accurately read analog force you need a load cell. This is what is used in a bathroom or letter scale for example.

There are other (generally less acurate and lower cost) technologies that use the spring constant of a material in combination with a distance sensing method. This resistive force sensor uses the spring constant of its internal polymer and the resistance vs thickness relationship to opperate. It will not provide nearly as linear of response as a load cell but would be simple to implement with a pwm analog sensing circuit like you were origionally intending.

• Or instead of distance just lumniosity increase Nov 20, 2017 at 6:21
• @joojaa, I guess if you are going down the route of making your own sensor from scratch; you could probably figure out a way to do it with light, but i would not recommend it. Lots of other solid options available. Nov 20, 2017 at 6:26
• thanks for the recommendations, a load cell does seem pretty interesting. The RFS looks nice as well. Are there assembled load cells as buttons? Nov 20, 2017 at 8:00
• @ericnutsch what are those other solid options that can be used with buttons? Nov 20, 2017 at 8:03
• @ericnutsch Allmost all commercial footpedals work thisway, its every solid options since it has no contact parts, so almost no parts that would wear down (and all components is available in most peoples bits box). All you need is a led and a light resistor, possibly a lght wane. It is much like a infrared distance sensor but aranged differently. Nov 20, 2017 at 8:03

"Quantum-tunnelling composite" is a rubber material impregnated with metallic particles. Its resistance varies as a function of mechanical pressure.

Basically, put a piece of QTC membrane between a pair of metal plates and squeeze it, the resistance of the QTC will decrease with an increase in pressure. This allows more or less current to flow from one contact to the other.

This stuff works remarkably well, I've used it as the lower half of a resistor voltage divider and you can get very smooth and reproducible results over a wide range of pressure. You can even use it to form a crude but effective speed controller for (very small) motors.

In your case you'd use the ADC of your microcontroller to measure the voltage and convert that into an integer value that quantifies the pressure on the button.

https://en.wikipedia.org/wiki/Quantum_tunnelling_composite

It's widely available and not very expensive if you only need a couple of square inches of it.