Using a mapped value which is then ramped analog output

Hi squd08,

It's hard to tell what you are trying to do from the code snippets you've included. You really should comment your code and explain what the variables mean.

May I suggest you replace the cascading if, else-if statements with a simple switch statement?

switch (adjenpos)
{
    case 1:  boostbtnout = map(boostbtnin, 0, 1023, 0, 51);  break;
    case 2:  boostbtnout = map(boostbtnin, 0, 1023, 0, 102);  break;
    Etc...
}

Or, even simpler, create an array of upper values that you index with adjenpos?

int switch_pos []= {51, 102, etc...};

...

boostbtnout = map(boostbtnin, 0, 1023, 0, switch_pos[adjenpos]);

// pardon my code if it doesn't compile, it's late for me and I'm a bit groggy :-/

I assume that what you are really wanting is a smooth transition between the current value and the new value based on switch position. You should store the current value in a variable and loop to the desired value (which may be up or down from it!). Use delays to ensure the transition is according to your 'prescribed' rate.