Increase/Decrease a variable Value on a press of a button

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Derrihj
Posts: 203
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 52 times
Been thanked: 20 times
Contact:

Increase/Decrease a variable Value on a press of a button

Postby Derrihj » Sat Nov 23, 2019 2:53 pm

Hi guys am happy to ask as many questions as i can and get as much info as i can so that in future i can write my projects with no more questions asked.Thanks to all of you guys that help me out.My next question is, how do we increase and decrease a variable with one button to increase it when pressed and the other button to deccrease the same variable when pressed? For example after reading the temperature and one may need to set a fixed value as Temp reference then one would use two buttons to increase or decrease values of "Temp ref" to a required value.I dont want to use a keypad for this simple job but would love to learn how to use two buttons.Thanks guys,you can help by witting a simple flow chat just to show the part of the two buttons in action.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8802
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2549 times
Been thanked: 3701 times
Contact:

Re: Increase/Decrease a variable Value on a press of a button

Postby medelec35 » Sat Nov 23, 2019 4:26 pm

Hi Derrihj ,
Attached is a simple way of setting temperature Reference variable between 5 and 30.
Attachments
Temperature Adjust 5 to 30.fcfx
(11.5 KiB) Downloaded 31 times
These users thanked the author medelec35 for the post (total 2):
QMESAR (Sat Nov 23, 2019 4:26 pm) • Derrihj (Sun Nov 24, 2019 12:43 am)
Rating: 10%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

Derrihj
Posts: 203
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 52 times
Been thanked: 20 times
Contact:

Re: Increase/Decrease a variable Value on a press of a button

Postby Derrihj » Sat Nov 23, 2019 11:03 pm

Hi Medelec35 and thanks for your quick response,ive added an LCD in your flow-chat so that i could see what is going on but the result i got is not exactly what am looking for yours goes from 30 t0 10 the goes to something like 70. But what i want is for temp ref to be adjustable from 0 to 30 and back from 30 to 0.Have a look at the flowchat with the LCD attached here. Thanks once again sir.
Attachments
Temperature Adjust 5 to 30Edited.fcfx
(13.88 KiB) Downloaded 21 times

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

Re: Increase/Decrease a variable Value on a press of a button

Postby mnf » Sat Nov 23, 2019 11:17 pm

When the temp goes from >= 10 to below 10 the second digit isn't cleared on the display.

So 10 -> 9 will display 90 which looks incorrect...

Martin
These users thanked the author mnf for the post (total 2):
medelec35 (Sat Nov 23, 2019 11:51 pm) • Derrihj (Sun Nov 24, 2019 12:40 am)
Rating: 10%
 

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8802
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2549 times
Been thanked: 3701 times
Contact:

Re: Increase/Decrease a variable Value on a press of a button

Postby medelec35 » Sat Nov 23, 2019 11:51 pm

Hi Derrihj,
Marin is correct in what he says.
I have modified your flowchart and removed the string as its not required
Attachments
Temperature Adjust 5 to 30 Edited1.fcfx
(13.29 KiB) Downloaded 28 times
These users thanked the author medelec35 for the post:
Derrihj (Sun Nov 24, 2019 12:41 am)
Rating: 5%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

Derrihj
Posts: 203
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 52 times
Been thanked: 20 times
Contact:

Re: Increase/Decrease a variable Value on a press of a button

Postby Derrihj » Sun Nov 24, 2019 12:10 am

Ok thanks Martin for that correction I edited it and i think now its working
Attachments
Temperature Adjust 5 to 30Edited WORKING NOW.fcfx
(15.22 KiB) Downloaded 32 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8802
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2549 times
Been thanked: 3701 times
Contact:

Re: Increase/Decrease a variable Value on a press of a button

Postby medelec35 » Sun Nov 24, 2019 12:27 am

Derrihj wrote: I edited it and i think now its working

Ok that's great, but your flowchart with additional string works the same as mine with the string removed,
As long as you are happy, that's the main thing.
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

Derrihj
Posts: 203
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 52 times
Been thanked: 20 times
Contact:

Re: Increase/Decrease a variable Value on a press of a button

Postby Derrihj » Sun Nov 24, 2019 12:32 am

Yes Medelec35 thanks for your work it has been so helpfull, ive seen yours and it works just the same as mine but correct me if am wrong coz one time i used the print Number comand and it had trouble printing Floating point numbers thats why i decided to use strings through out.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8802
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2549 times
Been thanked: 3701 times
Contact:

Re: Increase/Decrease a variable Value on a press of a button

Postby medelec35 » Sun Nov 24, 2019 12:54 am

Hi Derrihj,
Mine is not printing floating point, its printing bytes (0 to 255).
If you have a floating point, you can convert it to string (FloatToString function), then print string.
These users thanked the author medelec35 for the post:
Derrihj (Sun Nov 24, 2019 12:57 am)
Rating: 5%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.