Robojoy challenge class

2-1.Using the intelligent block


(Extra) Calculator program

Further develop to the calculated program 3, tried to make a calculator program. Although you can do only addition, we can find the answer by adding two numbers. Why do we need using a variable for the calculation? There is a benefit that you can create such a program.

This is the calculator program.
It is difficult to see the program that becomes too large, therefore, I will introduce the contents are divided into four parts.

The first process, has to display the "+" and "=".

This is the process, if the left button ran into. And displays increase the value of "variable_1". I am using a block called "loop block" and "switch block" to do the repeated branch processing. This will be introduced to the next.

This is the process, if the left button ran into. And displays increase the value of "variable_2".

This is the process, if the input button ran into.

When you run this program, it will be as follows.
First, "+"and "=" will be displayed on the screen.

Then, press the button on both left and right.

Then, the numbers will continue to increase under the red line. The number is only increasing when the button is pressed.

Calculation result is displayed, when you press enter (square) button. This is the calculator program. Although I think there is a disadvantage of being able to only addition, but if you improved it will be able to do the arithmetic operations.

[Download] Calculated Program 4 (for the NXT software)

I will introduce you "loop block" and "switch block" on the next.