count up a variable

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
ingoiot
Normal user
Posts: 43
Joined: 15 Aug 2019, 22:09

count up a variable

#1 Post by ingoiot » 19 Oct 2019, 21:15

hi i'm trying to count up /down a value that i initialized at boot, with two buttons.

Code: Select all

On System#Boot do    //When the ESP boots, do

//[DummyVar#TempSetpoint]=40
TaskValueSet 3,1,40

endon


on ButtonLeft#state=0 do

//[DummyVar#TempSetpoint]-
TaskValueSet 3,1,-1

endon

on ButtonRight#state=0 do

//[DummyVar#TempSetpoint]+
TaskValueSet 3,1,+1

endon
i wanted this value to be set at boot or later with a http send via an app,
and increase/decrease it locally via Buttons.

it gets set at boot to 40 like i want but unfortunately,
when i press a button its set to 1 or -1 not to 41,42,43 and so on.

Domosapiens
Normal user
Posts: 291
Joined: 06 Nov 2016, 13:45

Re: count up a variable

#2 Post by Domosapiens » 19 Oct 2019, 21:25

You need to mention the name of your variable [DummyVar#TempSetpoint] and operate on the content, therefor the []

Code: Select all

On System#Boot do    //When the ESP boots, do

//[DummyVar#TempSetpoint]=40
TaskValueSet 3,1,40

endon


on ButtonLeft#state=0 do

//[DummyVar#TempSetpoint]-
TaskValueSet 3,1,[DummyVar#TempSetpoint]-1

endon

on ButtonRight#state=0 do

//[DummyVar#TempSetpoint]+
TaskValueSet 3,1,[DummyVar#TempSetpoint]+1

endon
I think this will work.
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

ingoiot
Normal user
Posts: 43
Joined: 15 Aug 2019, 22:09

Re: count up a variable

#3 Post by ingoiot » 19 Oct 2019, 21:41

I think this will work.
indeed it did , tnx.

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests