Robotics Test Review

Variables
“A way to store a value in memory of a certain size, and have it accessible by name”

Types that we have used:

  • Word (numbers range from 0-16534)
  • Nib (numbers range from 0-15)

ex:
myCounter VAR Word

ex:
someVariable VAR Nib
IF/ELSEIF/ELSE
“A conditional statement. A way to run specific code for specific conditions.”
ex:
test VAR Word
test = 40

IF (test < 30) THEN

GOSUB FIRST_SUB

ELSEIF (test > 50) THEN

GOSUB SECOND_SUB

ELSE

GOSUB THIRD_SUB

ENDIF

‘ Which routine is run?

 

Subroutines
“A subroutine is simply a specific piece of code (often one that is used repeatedly) that is written as a unit, then called.”

example use:
GOSUB MY_SUBROUTINE

example declaration:
MY_SUBROUTINE:

‘do something here

RETURN
DO/LOOP
“A loop that will continue to repeat indefinitely.”
ex:

DO

‘do something here, that will be repeated indefinitely

LOOP
FOR/NEXT
“A loop that uses a variable to count how many times to loop.

ex:
(Assuming a variable called “loopCounter” has been declared)

FOR loopCounter = 0 to 40

‘do something here, that will be repeated how many times?

NEXT

 

Comments are closed.