How to perform keypad as a calculator

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
Jacob1
Posts: 35
Joined: Wed Dec 27, 2017 4:18 pm
Has thanked: 7 times
Been thanked: 6 times
Contact:

How to perform keypad as a calculator

Post by Jacob1 »

Hello,

I wondered if anyone would be able to perform a keypad as a calculator. I trying to create program which adds two numbers under 9999. Eg I enter 1,2,8 and then press * to add and then enter 3,4,7 and press # to = these numbers. So 128 + 347 = 475. Ive attached what I have created at the moment

Thanks in advance for all your help
Jac
Attachments
ex 9 prog 2.fcfx
(11.23 KiB) Downloaded 303 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: How to perform keypad as a calculator

Post by medelec35 »

Hi Jac,
If the result is going to be greater than 255, then don't use a byte as the maximum value of bytes is only 255.

I did a flowchart for Flowcode V5 some time ago that adds two numbers together.
Take a look here.

Martin
Martin

Jacob1
Posts: 35
Joined: Wed Dec 27, 2017 4:18 pm
Has thanked: 7 times
Been thanked: 6 times
Contact:

Re: How to perform keypad as a calculator

Post by Jacob1 »

Hi,

This is for flow code 5, is there anyway you can convert it to flow code 7 or explain how the program works?

Cheers
Jac

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: How to perform keypad as a calculator

Post by medelec35 »

Flowcode7 is designed to load Flowcode 5 fcf files.
Run Flowcode, Select Open project (or File, Open).
Change drop down box next to file name from

Code: Select all

Flowcode project files (*.fcfx)
to

Code: Select all

Flowcode for PIC files (*.fcf)
Then you can open .fcf files.

Martin
Martin

Jacob1
Posts: 35
Joined: Wed Dec 27, 2017 4:18 pm
Has thanked: 7 times
Been thanked: 6 times
Contact:

Re: How to perform keypad as a calculator

Post by Jacob1 »

Hi,

I will try and dissect the program later on. Can I ask what 10 and 11 represent in the switch icon? And is there meant to be a display result empty macro?

Thanks a lot
jac

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: How to perform keypad as a calculator

Post by medelec35 »

Code: Select all

10 = *

Code: Select all

11 = #
Jacob1 wrote:And is there meant to be a display result empty macro?
No there is not. I have just loaded V5 Flowchart in v7 and:
Display Result.png
(35.65 KiB) Downloaded 2415 times
Martin
Martin

Jacob1
Posts: 35
Joined: Wed Dec 27, 2017 4:18 pm
Has thanked: 7 times
Been thanked: 6 times
Contact:

Re: How to perform keypad as a calculator

Post by Jacob1 »

Hi medelec35,

Yeah sorry for some reason the macro flowchart didn't show when i first downloaded it. Could you explain what the number = (number* 10) + key means? I'm guessing the result and number are the two values which are added. Also, The display result macro converts the number into a string and then displays this, but why is there then a second loop with the until = key

Thanks for your help
Jac

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: How to perform keypad as a calculator

Post by medelec35 »

See if you can find out what is going on by adding all variables to simulation debugger then work out what you think should happen.
Then use F8 to step into and see if you was correct in your assumption.
You could also disable the loop and see what affect it has.
Worth spending a fair bit of time in the simulation to see if you can work it all out.
Martin

Jacob1
Posts: 35
Joined: Wed Dec 27, 2017 4:18 pm
Has thanked: 7 times
Been thanked: 6 times
Contact:

Re: How to perform keypad as a calculator

Post by Jacob1 »

Hi,

Wondered if anyone knows how to assign a space to the button * for example? I am having trouble with this, and have looked at previous forum posts. One post seemed to use the variable = variable + 2 in order to skip to the next space with a decision which says "key press = decimal value according to the keypad symbol. I have tried this but I cant seem to get it to work, as I am using different variables. I have attached the program below, which is basically a mobile phone but I want to be able to insert a space when the * button is pressed

Also, the display can only show 9 characters before a random number is shown which is another problem, changing the string size doesn't affect this or the variable size used, such as Ulong or int.

I would also like to say that I have used the principles of martins calculator program for this that he posted on here, I would like to thank him for showing this example to me in the first place!

Thanks
Jac

Post Reply