9. Practical Guide\9.8 Using Variables

9.8  Using Variables

Program a robot to pick up the RED objects in the virtual world. It will stop collecting if the robot has collected 6 objects. It means the robot will not even stop and blinks LED when it detects the RED object after collecting 6 objects.

Analysis:

There are many pre-defined internal variables can be used for programming. One of these is the “LoadedObjects”. It is the object counter. It counts the object collected. When the key action “FindObject” is executed, the “LoadedObjects” is increased by 1.

We can access the “LoadedObjects” variable in the program to block robot from collecting objects once LoadedObjects = 6.

Procedure:

1.    Open the project “SearchingRED”.

2.    Include the “LoadedObjects<6” in the advanced condition. This means that the robot will only stops and flashes its LED when the robot detects the RED object if the LoadedObjects <6.

3.    Save the project as “SearchingRED_6”.

4.    Build the project.

5.    Load the “SearchingRED_6.dll” to the RED robot and monitor its performance.

 

 

Top of Page