Increase/Decrease a variable Value on a press of a button
Moderator: Benj
-
- 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
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.
-
- Matrix Staff
- Posts: 9521
- 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
Hi Derrihj ,
Attached is a simple way of setting temperature Reference variable between 5 and 30.
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 188 times
Martin
-
- 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
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 194 times
-
- Valued Contributor
- Posts: 1200
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Increase/Decrease a variable Value on a press of a button
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
So 10 -> 9 will display 90 which looks incorrect...
Martin
-
- Matrix Staff
- Posts: 9521
- 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
Hi Derrihj,
Marin is correct in what he says.
I have modified your flowchart and removed the string as its not required
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 187 times
Martin
-
- 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
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 206 times
-
- Matrix Staff
- Posts: 9521
- 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
Ok that's great, but your flowchart with additional string works the same as mine with the string removed,Derrihj wrote: I edited it and i think now its working
As long as you are happy, that's the main thing.
Martin
-
- 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
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.
-
- Matrix Staff
- Posts: 9521
- 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
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.
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