Linear to V curve

Hello all

I have a potentiometer which give linear output 0 to 5Vdc i need to form a Vcurve out of it.

Means AT

0V of potentiometer i want 5Vdc

2.5V of potentiometer i want 0Vdc

5V of potentiometer i want 5Vdc

Please suggest how to do it. on PWM channel even it can do than i will convert with resistor capacitor to voltage.

Well, assumung you’re using a 5V Arduino board with 10-bit ADC, your ADC input will vary 0-5V giving 0-1023 reading value.

For 0-512 reading, you want newValue = 1023-0.
For 513-1023, you want newValue = 2-1023.
PWM = newValue/4 (255-0-255 = 5V-0V-5V filtered).

Note: It’s possible to use 10-bit PWM (1023-0-1023) at 15.625kHz frequency for more accurate filtering with less ripple, but I would develope your code and get it working as above first. Give it a try then post your code using the “</>” code tag button.