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: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
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.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
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 172 times
Martin

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
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 172 times

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
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 172 times
Martin

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
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 186 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
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

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
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.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
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

Post Reply