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

Post Reply
Derrihj
Posts: 218
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

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

Post by Derrihj »

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: 8873
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

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

Post by medelec35 »

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 40 times
Martin

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

Derrihj
Posts: 218
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

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

Post by Derrihj »

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 29 times

mnf
Valued Contributor
Valued Contributor
Posts: 723
Joined: Wed May 31, 2017 11:57 am
Contact:

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

Post by mnf »

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8873
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

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

Post by medelec35 »

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 38 times
Martin

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

Derrihj
Posts: 218
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

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

Post by Derrihj »

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 40 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8873
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

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

Post by medelec35 »

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: 218
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

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

Post by Derrihj »

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: 8873
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

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

Post by medelec35 »

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.
Martin

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

Post Reply