Hi Blynkers,
Small issue here…I have a Numeric Input Widget set to 0.25 steps (0-10 in increments of 0.25) which writes its value to a Gauge Widget which label setting is set at “/pin.##/” so as to display a value with 2 decimal places. The issue is as you change the Numeric Input Widget by the set 0.25 step the Gauge Widget only acknowledges the whole number so it increments at every 4 steps by 1. Can someone please explain why?
Still have a slight issue here. The 2 decimal numbers show up now but for some reason the mapping calculation is wrong. Any ideas why ( CalcSt is a float) ie. 1.25 should output 3750, 1.50 should output 4500 and so on
I’d forgotten (or probably never realised) exactly how the Map function worked.
The solution is simple though. Multiply your result by 100 and either change your Map parameters or divide by 100 and use your existing Map values.
A further issue with this…the mapping function with the math formatting works. But how do I get a value from the BLYNK_WRITE function to a void function? I need a value from CycleTime and then taken to be used in the CycleTime in void FeedPump(), as there is no syntax like Blynk.virtualRead. I have read the Blynk documentation and the example they show does not suit this case
BLYNK_WRITE(V4) //Numeric Input Widget
{
CalcSt = (param.asFloat()*100);
CycleTime = map(CalcSt, 0, 10, 0, 30000);
Blynk.virtualWrite(V5, (CalcSt/100)); //Send value to gauge display
Serial.print(CalcSt/100);
Serial.print(" : " );
Serial.println();
}
void FeedPump()
{
if (StepPump.check() == 1)
{
if (StepState == HIGH)
{
StepPump.interval(CycleTime/100); //On time 0-5000l/h
Serial.print ( CycleTime/100);
Blynk.virtualWrite(V7, 255);
StepState = LOW;
}
else
{
StepPump.interval(75000); //Cycle gap 1min 15sec
Blynk.virtualWrite(V7, 0);
StepState = HIGH;
}
digitalWrite(FeedPin, !StepState); //Switch stepper pump pin on
digitalWrite(LedFeed, StepState); //Switch stepper LED on
}
}