• Select the letters, mathematical symbols and numbers from the keypad or type them
in. To edit: Use the ‘C’ key to clear or highlight and delete using your keyboard.
A variable is a letter or word that can be assigned a value.
e.g. Make x = 0 OR Make SwitchCount = 1.
The variable and its value will not ‘exist’ until it is created by the control program being run.
The value of the variable can be observed (once created by the program) in the Variable
panel.
NOTE: If more than one word is used for a variable name, there should be no spaces
between words. Capital letters may be used to help distinguish words as shown in the
example above.
The variables are global, so the value of a variable in one flowchart will be ‘seen’ by all the
other flowcharts and procedures in the control program.
Standard mathematical operators can be used within this function; addition, subtraction,
multiplication and division.
e.g. Make x = x + 5 OR Make x = x / 3 OR Make x = x * 2
NOTE: Variables are stored to 1 decimal place and can be in the range ±107374182.3.
• A variable can be used to store information.
For example:
In an Elevator program we could store the current floor in a variable called
‘floor’ by using Make floor =1. This allows us to check later in the program to
see what floor we are on and which direction we have to move in to get the
new floor. (i.e. If we need to go to level 2 and the floor variable tells us we are
currently on 1, then we need to go up!)
• The value of a variable can be checked by a decision symbol (Is Variable x > 5).
For example:
If the pushbutton has been pressed 6 times, shut the model off.
• Random can be used to generate a random decimal between 0.000 and 0.999.
A decision symbol can be used to check for a random number.
Seconds
Seconds is a free running timer that starts from zero to give the elapsed time (in seconds)
since a program was started.
K’NEX Robotics User’s Guide
Education
®
Building Programs
education.com
Education
®
Building Programs
39
SOFTWARE