Flex sensor continuous self-calibration setup

Hello,

I’ve built a sensory extension helmet equipped with human scale cat whiskers that when flexed triggers a vibrating motor disc (additionally, the motor intensity is proportional to the bend angle magnitude). The whiskers utilize 4" unidirectional flex/bend sensors to track resistance change upon contact with an object.

The code (attached) I’m currently using works fine with regard to conversion to resistance, re-mapping to bend angle, and re-re-mapping to a vibration motor output. I have a major problem though…the base resistance of the flex sensor changes quite frequently and the code-as-written doesn’t take this fluctuation into account. Every time I boot up the helmet I have to set/calibrate “STRAIGHT_RESISTANCE” and “BEND_RESISTANCE” values. More problematic is that, once the whiskers are bent a few times, the new actual baseline resistance value is different than the original “STRAIGHT_RESISTANCE” value.

I need help figuring out how to alter the code to take this into account. It seems apt to call this sort of function continuous self-calibration. To note: I’m relatively new to programming, so please keep that in mind. Any assistance would be greatly appreciated!

Flex_Sensor_Tactile_Display_Combined.ino (2.28 KB)

I need help figuring out how to alter the code to take this into account.

You have not provided near enough detail to make me even look at the code, yet.

The code (attached) I’m currently using works fine with regard to conversion to resistance

That conversion is based on what? Some known formula?

I have a major problem though…the base resistance of the flex sensor changes quite frequently

Why does this happen? How is the Arduino to know that this has happened? How is it to determine the new relationship between resistance and angle?