Advice needed: changing a value

RE-EDIT due to misunderstanding.

I have a thermostat for which I like to change the Target temperature. This value is shown in the blynk app in a ‘Value Display’ on virtual pin: V(3).

I also have ‘Step H’ widget (+/-) on the Blynk app with which I can change that same value.

The current problem is that I cannot set the Step H widget on V(3) as well (you get the ‘busy’ indicator). So I HAVE to use another Vpin: V(4) to operate the Step H.

I was wondering whether there’s not a more elegant solution where I only need to use 1 virtual pin instead of 2.
With that I mean: is there an (possibly: entirely) different method with which you can omit the requirement of using 2 virtual pins?

Note that I’m not stuck on H/V Step nor the ‘value display’ I just want some interactive way to change the value through the Blynk app AND show it properly on screen.

At the moment you need to use 2 different pins.

I know, I was just curious if someone thought of an entirely different method to deal with this?

you can do it with using one virtual pin. You need to compare with last value. For example;

if (value > last value) {
  //increase 
  last value = value;
} 

if (value < last value) {
 //decrease
last value = value;
}

@yilmazyurdakul: I’m not following you. How does this help me with displaying a value and changing it with (e.g.) the step h widget? Could you elaborate/

I understand your problem like that;

You need to control two buttons with step widget. when you increase step widget, first button will work, when you decrease step widget, second button will work.

Is that true?

If it is true, first of all you must get value from virtual pin.

BLYNK_WRITE(V0) {
  value = param.asInt();
}

//Than you must compare your value. If you increase, first state will work. decrease second...

if (value > oldValue) {
 
 //Increase button or something...
oldValue = value; // You must store your old value
}

if (value < oldValue) {

  //Decrease something...

 oldValue = value; //Store...

}

PS: You can get old value from another virtual pin to get synced. It will help to go on after reboot

ah, no! I was talking about two PHYSICAL (solid, you can touch them, electronics behind them etc) buttons. The “Value Display” can be changed by either pressing those buttons and/or by using a “Step H” widget.

What I want ‘changed’ is the ‘Value display’ this shows target temperature on V(3) now if I hit the physical buttons the ESP simply updates V(3) with the new value (either one step up or down). However when I want to use the Step H I cannot use V(3) as its in use by the ‘Value display’ already. So I currently need to use V(4), detect the change, process it and then update V(3).

Now I’m aware that there is NO way around this. Hence I’m looking for advice to ‘do this’ (entirely) differently (if there is such a method). Its really a rather general question on is their ANY other method in blynk where you can update a value AND properly show it on screen without the requirement of multiple pins.

Still i can give the same answer. You can control oldValue variable with phisical button and widget.

If (digitalRead(2) == HIGH) {

 oldValue++;

}

You can sync old states to application.

I apparently completely failed in getting across that which I wanted to achieve. I’ve rewritten the first post and removed any references to the physical buttons as they completely don’t matter, I didn’t realise this was so confusing.

Please reread the first post (preferably as if its a completely new question) and see if you can answer it! Thank you!

I saw your edit. You removed physical buttons. I guess it changes all construction in codes. If you have a time, i can work on it. Because i am working on my PhD articles nowadays :frowning:

I did your previous question about physical buttons. That was really great. If i find that, i will post it to you. I need to check something about your updated question. I wrote all these posts during my science lesson :smiley:

well, you don’t really have to ‘work’ on it. Just a suggestion on how I could approach it differently would be great!
Thank you.

As @Eugene said, you have to use two separate virtual pins.

The only widget that I’m aware of that can share a V pin is Superchart, but using Superchart isn’t really a good way of displaying your target temperature (although it may be handy to plot target and actual temperature in Superchart for other reasons).

For me, the real problem is the Step widget. The up/down (or left/right) buttons aren’t very substantial icons and the value display is tiny. I’d like to see proper buttons and either a proper display, or the option to hide the small display so that a value or labelled value widget can be used instead.

The good news is that the code you need to run to mirror the changed value from the step widget over to the value display is very simple.

Pete.

@PeteKnight thanks for the answer. and yes the small text is the issue. I have the code in place but interestingly enough I’m close to running out of virtual pins (with 128 set !!). Its working for now, but I was hoping for an alternative.

We have in plans to get rid of ‘busy’ pins and making all of them available for usage in multiple widgets. Stay tuned! :wink:

1 Like