BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Stepper widget automatically rounds number


#1

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?


#2

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/


#3

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


#4

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

float stepperState = param.asFloat();


#5

Ahhhhh i was being stoopid thanks


#6

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: