# Exponential function and arduino ! help !

Hello everyone,
what I am trying to do here is controlling a servo with a potentiometer with PWM break through board in between. Now this is not the problem because I managed to make the program work well regarding this matter. My problem is that I am trying to make the potentiometer value go up and down exponentially. So I need your help doing the math with arduino. So how can I do this ?

my code so far for the calculation but we can ignore the PWM board and work as if the servo is connected directly to the arduino pin and at the moment the servo is not consistant, it goes bit by bit :

``````float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

void loop() {
Serial.print("PotValue: ");
Serial.println(throttlePotValue);
throttlePotValue = mapfloat(throttlePotValue, 0, 1022, 0, 6.3); // 135 min and 575 max
Serial.print("throttlePotValue: ");
Serial.println(throttlePotValue);
float throttleExpValue = exp(throttlePotValue);
Serial.print("throttleExpValue: ");
Serial.println(throttleExpValue);
int throttleValue = map(throttleExpValue, 0, 544, 135, 575);
Serial.print("throttleValue: ");
Serial.println(throttleValue);
delay(500);
// Min value for the mini servo is 125 not less
pwm.setPWM(0, 0, throttleValue);

}
``````

I am trying to make the potentiometer value go up and down exponentially

Explain why you mean by this, and give some numerical examples.

Also, explain what this line is supposed to do. It makes no sense to me.

``````int throttleValue = map(throttleExpValue, 0, 544, 135, 575);
``````

jremington:
Explain why you mean by this, and give some numerical examples.

I mean if I turn the pot a little bit, the servo will turn a bigger angle

jremington:
Also, explain what this line is supposed to do. It makes no sense to me.

``````int throttleValue = map(throttleExpValue, 0, 544, 135, 575);
``````

the 135 and 575 are the maximum input for the pwm. function of the PWM board. We can ignore this and use the normal pot and servo connected directly to arduino

I mean if I turn the pot a little bit, the servo will turn a bigger angle

Numbers, please. The Arduino does not understand "a little bit" or "a bigger angle".

Get a log type potentiometer.

Have a look in math.h