04VariablesTimers

04VariablesTimers - Variables in the RCX graphical language...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Variables and Timers COMP106 Variable • A variable is a memory location where you can store temporary results. • A variable can be used as a parameter to any of the big blocks. 1. SET Side TO 1 2. Forward Side Seconds 3. Backward Side Seconds
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Variable • There is a built-in variable: counter1 • But, how to add more variables to your program? Variable • By default, all the variables at the time of being defined, are set to have the value of 1. • All the variables can only hold integers. • To changes the values stored in the variables, just use the variable commands in small blocks. • You can do Add, Subtract, Multiply, divide, and other operations on the variables.
Background image of page 2
Variable • Then, how many variables, at maximum, can you use?
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Variables in the RCX graphical language are usually defined as global. Something bad about this? We will discuss this later. The answer is 32. Timer There are 3 timers (Timer 1, Timer 2, and Timer 3) within the RCX. Timers are like stop watches. They all start running when you start the program. You can read from any of the 3 timers at any time. You can use the timer value in conditions or set it to a variable. You can also restart(reset) the timers. Timer Examples: 1. Reset Timer 1 2. Repeat until Timer 1 >= 10 seconds 2.1 Forward 20 second 3. EndRepeat 1. Reset Timer 1 2. Repeat 10 Times 2.1 Forward 1 second 3. EndRepeat 4. Set X to Timer 1 5. Backward X seconds...
View Full Document

Page1 / 4

04VariablesTimers - Variables in the RCX graphical language...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online