Can't find anything online to work it out for me, going to be using to get a nicer brightness change than simply decreasing the analogwrite by 1 in a loop.
I can do the adjusting to fit my x/y range, I just need something to get that kind of curve
That is useful for later, but I specifically need that flat horizontal part at x=200 to 255, I'm making a little midi visualiser, so I want the light to stay bright for a bit when the key is pressed, but then smoothly transition into the quick decrease in brightness.
Same priciple.
Make a lookup table for the brightness steps you want,
and then analogWrite the corresponding lookup table value to the LED.
A 16 or 32 value lookup table could be enough.
Leo..
Do you want that as the control for the light or do you it to visual look like that?
Note, those are NOT the same Because our perception of light is kind of logarithmic. Have a look at Gamma correction. To visual have it to look like that you need to pass that function through a gamma correction function.
Next, to get a function for your graph you can use Excel. If you make a plot of those points (XY / scatter plot) you can let Excel make a formula for that (add trend line). BUT, don't use that in a (8-bit) microcontroller! That is pretty heavy to calculate. Better is to make a look up table or a lookup table of this and gamma correction combined.
For gamma correction you can use my library FadeLed. You don't need to use the fade part if you use .begin(value) instead of .set(values) which will set the output without fading but with gamma correction. You can also make a custom table to include/substitute your graph.
It looks like an arctan curve. You can trace it using Google, just type arctan(x)
I'd say it should be something like a+b*arctan ((x-c) /d) where a, b, c and d are parameters to find.
It is not very complicated to find them. The standard arctan function ranges between -pi/2 and +pi/2 and your graph between 0 and 270 so a should be equal to 270/2 and b to 270/pi
c is the abscissa value at which the curve passes midway so it's roughly 195.
d should be found by trial and errors, as it is a scaling coefficient