I'm finishing my code to control some leds with PWM...
It happens that my calculations are float... (Eg: 244.1, 244.2 ... 244.9)
Between 244.1 and 244.9 the light behaviour should have some minutes... With PWM as integer, pass through directly from 244 to 245 don't let me satisfied...
analogWrite... analogWrite(uint8_t pin, int val)
What do you suggest... beside that my values (calculations) are float...
Between 244.1 and 244.9 the light behaviour should have some minutes
Are you saying you should be able to see the difference between a PWM value of 244.1 and 244.8?
No, in fact I'd be surprised if you could see a difference between 244 and 255.
You could try mapping the range you are interested in to a wider one, e.g. if you only ever get values of say 240 to 245, then make 240 PWM 0, and make 245 PWM 255.
In fact, I don't know if between 254-255 exist too much light difference.. but on my algorithm the gap between them is about some seconds...minutes...
Don't have funny transform float behaviours to integer behaviours...
You may need to make some version of map() to work in your application. Create a function that you can pass your (float) to and get back an appropriate (int) for the PWM.
Or, modify your calculations to yield usable integers.
float value;
const float MinimumValue = 244.1;
const float MaximumValue = 244.9;
...
// Map the range of analog values into the integer range 0-255
unsigned int pwm = ((value - MinimumValue) / (MaximumValue-MinimumValue)) * 255U;
analogWrite(LED_pin, pwm);