Stepper widget automatically rounds number

So I’m using a stepper widget which has a step of 0.5 in range of 0.5 to 3. When I print the value of the widget to the serial the number is rounded down for example, if i selected 2.5 the serial would print 2 instead. How do I get the actual I selected?

Since I can’t read your code I can only guess that you are using the wrong data type on a variable.

https://www.arduino.cc/reference/en/language/variables/data-types/float/

Sorry i left out my code, here is my original code:
BLYNK_WRITE(V1) // stepper
{
float stepperState = param.asInt();
Serial.print(stepperState);
}

Even if i do:
Serial.print(param.asInt())
it will still round the actual value of the slider down

Can’t check it myself, but perhaps this will work?

float stepperState = param.asFloat();

2 Likes

Ahhhhh i was being stoopid thanks

1 Like

You’re not the first, nor the last to do a face plant when the obvious stares you right in the eye! :rofl:

I tend to confess my stupidness in old threads that nobody reads or cares about :laughing: :innocent:

1 Like