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 (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);

   //Set the Output Range to 0-10V (equals 0 - 4096)

void loop() 
  // Read in the soft pot's ADC value
  // SP_Read is between 0 and 1023
  int SP_Read = analogRead(SP_Pin);

  // 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!


A data sheet for your SoftPot could be helpful.

If you are sure that the pot only has 2 pins, you can determine the position (resistance) like this:

The voltage on the pulldown resistor is proportional to the total current (U=R*I). The current is proportional to the supplied voltage and the total resistance (pot+pulldown) (I=U/(R1+R2), or (R1+R2)=U/I). This should (untested) result in

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