How to multiply or add or devide a "param.asInt" value with another "param.asInt" value?

I want to multiply or add or devide a “param.asint” value of a virtual pin, with another “param.asint” value of another virtual pin…

It’s like:

Blynk_Write(V1, V2);


… servo.write((param.asint of V1) ÷ (param.asint of V2));

It’s just my imagination code…which is not valid…i am trying to give you an idea about what i want.

I’ll be greatfull if anyone can tell me how to write the code…:heart:

First of all, each BLYNK_WRITE(vPin) callback function is handled individually, so you can’t have this:

I’d suggest you declare two GLOBAL variables, lets call them widget_a and widget_b as you haven’t told us what the widget types or functionality are.
We’d probably need another one for the result, so we’ll call this math_result

Then, when one of the BLYNK_WRITE(vPin) callbacks are triggered, you store the incoming value to the corresponding global; variable.

You then have a number of options - do the maths in each of the two BLYNK_WRITE(vPin) calbacks, or (and this is the neater option) put the maths in a single separate function and call it from your BLYNK_WRITE(vPin) callbacks.

The code could look something like this…

int widget_a;
int widget_b;
int math_result;

  widget_a = param.asint();

  widget_b = param.asint();

void do_the_math()
  math_result = widget_a / widget_b;
  Serial.print("The result is.. ");
  // maybe write the result to your servo here?...


1 Like

I do not know how to thank you🥺.
I spend a lot of time to write this specific code. But I do not know coding that much. You could not realise how much your Knowledge going to help me🥺.
I will inform you, if I get any problem later.
I hope I Will get more help from you later. Thank you so much Sir…

May Allah bless you❤️

1 Like