# Softpot and Pulldownresistor - How do i achieve linearity?

Hi everybody.

I'm currently working on a project where I'd like to use a Softpot as kind of like a Musical Keyboard.
I'm using an Arduino Uno, a linear Softpot with a maximal resistance of 20k, a 10k Pulldownresistor, and this shield GitHub - shaduzlabs/synapse: Arduino CV/Gate I/O shield and its software library (just used as a DAC for the Output)

Theoretically, the reading of the Softpot without a Pulldownresistor would be linear, which is quite essential for my Project to work. But without a Pulldownresistor my inputpin floats if the softpot is not pressed.

So my Idea was, to somehow fix the linearity with equations between reading in the softpot value, and writing a value to my ADC.

Can someone tell me how you would calculate that? I just don't get it.

Here's the simple code I use up to now:

``````#include <Synapse.h>
using namespace sl;
#include <DirectIO.h>

const int SP_Pin = A2; // Pin connected to softpot wiper

void setup()
{
pinMode(SP_Pin, INPUT);
SynapseShield.begin();

//Set the Output Range to 0-10V (equals 0 - 4096)
SynapseShield.setCVRange(
Synapse::CVChannel::A,
Synapse::Range::ZeroToTenVolts);
}

void loop()
{
// SP_Read is between 0 and 1023

// scale SP_Write to 0 - 2048, for 0-5V Output
int CVa_Write = map(SP_Read, 0, 1023, 0, 2048);

// Write CV on Channel A
SynapseShield.writeCV(Synapse::CVChannel::A, CVa_Write);
``````

}

All the SynapseShield Stuff comes from the library of the shield, and should be negligible to solve my Problem.
Essentially I need to convert the Softpot's Input range from 0-1023 to a linear output range from 0-2046.

I'm really stuck at this point, and would appreciate any help!

Best,
Till

`````` Rpot = (Rpulldown * 1024.0 / analogRead(Ax)) - Rpulldown;