Hi all,
I am building a calculator using a PICAXE-18X chip for my A Level Systems and Control project.
I am currently trying to add two 1-digit numbers together. I am able to correctly take input from my keypad, display the number entered, and save the value of the key entered to a variable.
However when I try to add two variables, and output the result, it fails. My code for the main sub is below:
<code>
Symbol key_number = b0
Symbol value_1 = b1
Symbol value_2 = b2
Symbol answer = b3
main:
do
gosub check_for_key
loop until key_number !=0
gosub display_number
value_1 = key_number
key_number = 0
wait 2
do
gosub check_for_key
loop until key_number !=0
wait 2
gosub display_number
value_2 = key_number
key_number = 0
answer = value_1 + value_2
wait 2
key_number = answer
gosub display_number
</code>
Both the 'check_for_key' and 'display_number' subroutines work fine. Any ideas?
All help appreciated,
Thanks in advance,
David
I am building a calculator using a PICAXE-18X chip for my A Level Systems and Control project.
I am currently trying to add two 1-digit numbers together. I am able to correctly take input from my keypad, display the number entered, and save the value of the key entered to a variable.
However when I try to add two variables, and output the result, it fails. My code for the main sub is below:
<code>
Symbol key_number = b0
Symbol value_1 = b1
Symbol value_2 = b2
Symbol answer = b3
main:
do
gosub check_for_key
loop until key_number !=0
gosub display_number
value_1 = key_number
key_number = 0
wait 2
do
gosub check_for_key
loop until key_number !=0
wait 2
gosub display_number
value_2 = key_number
key_number = 0
answer = value_1 + value_2
wait 2
key_number = answer
gosub display_number
</code>
Both the 'check_for_key' and 'display_number' subroutines work fine. Any ideas?
All help appreciated,
Thanks in advance,
David