Programming Highlights

 

 

The following section, Programming Highlights, discusses important learning points about programming that should be explored by the students. You may choose to discuss them with the whole class or group by group as they arise during studentsí work.

 

Downloading a program and setting the program slot

 For a program to run, it has to be downloaded to the RCX. The RCX can hold one program in each of its five program slots. Each time a program is downloaded into a slot, it overwrites the old program. Therefore, it is important to know which one is the active program slot. Use the Program Setting menu on the screen to check or change the program slot.

Wizard

Return to top

How is ON AC different from On AC for 1?

The On AC block turns on the motors connected to output Ports A and C for an unspecified length of time. To turn them off, the block Off AC must be used. However, if the Off block is used immediately after the On block, the motors will turn on for a fraction of a second hardly noticeable and then immediately turn off. To have the motors run for a while, you must delay the onset of the Off command. This is done by inserting a Wait for block, which specifies the number of seconds before the program carries out the Off command.

The On AC for 1 block actually combines three commands into oneóOn AC; Wait for 1; Off AC. Thatís why thereís no need to turn the motors off after using this command.

Executing Blocks. Observing behavior. Consider a simple stack of blocks containing power commands such as On, On for, or Off. The blocks execute in a top-down fashion. When the first block finished executing, the program drops to the next block, and so on. Different blocks take different amounts of time to execute. For example, the On block, executes in a flash; the On AC for 3 block takes 3 seconds to execute. It is very important to make a distinction between the time it takes a block to execute and how long the resulting behavior lasts. In the above example, it takes a flash for the On block to execute, but the motors turned on by the block will stay on until another block turns them off. 

Here are some examples to illustrate this point.

Return to top

What does the command Reverse Direction do?

The Reverse Direction command is not a movement command (It does not turn on motors). It is an orientation command, pointing the motors to move in the opposite direction when they are turned on.

Motors do not have to be turned on in order to reverse direction.

If a motor is already turned on, it will run in the opposite direction as soon as the program carries out the reverse direction block.

If a motor is not turned on, it is going to be prepared to move in the opposite direction, but itís not going to actually move until itís turned on.

Hereís an illustration of this distinction: The programs Needed and NotNeeded relate to whether an On AC block is needed or is not needed for the motors to continue to run.

Return to top

How is Reverse Direction different from Set Direction?

 Reverse Direction changes the direction in which a motor is currently running to its opposite. Set Direction sets the direction a motor should turn in regardless of the direction it was turning prior to carrying out the Set Direction command.

In other words, Reverse Direction is relative to a prior state, while Set Direction is absolute and does not depend on what was happening previously. 

    

 © The LEGO Group

For a helpful illustration, see Set Direction and Reverse Direction in the Help menu.

Return to top

Wait for!

The Wait for block delays the execution of the command block that follows it. It has no effect on any command block above it in the stack. On the flip side of the Wait for block, you can specify the number of seconds the onset of the next block should be delayed. (You can use whole numbers or decimals.)

Here are two examples.

 

Tech Guide

 

 

 

 

 

 

 

Tech Guide

Tech Guide

 

 

 

Tech Guide

 

 

 

 

Tech Guide

 

 

Tech Guide

 

 

 

 

 

 

 

 

 

 

 

 

Tech Guide

 

 

Tech Guide

 

  

 

 

 

 

 

Tech Guide

If needed, have students evaluate short stacks to help them understand how commands relate to each other. Use Transparency #1 to help you guide the discussion.

 

Return to top