Computing / Computer Science

Phases of a program


With all programming languages, there is an inherent order that certain instructions should be performed in. This behavior dictates were certain types of instructions are placed in the program. By using a template, we can streamline the creation process and build a uniform framework that all of our programs follow. The first step is to identify generic regions based on the actions taken by the NXT. Let's break apart our sample code and see how it is organized:

motor [ sLabel ]




In programming, a variable is a labeled section of memory that holds a specific data value. Once we create this variable, the data contained can be referenced multiple times. When you use a variable as a parameter of a function, the value of that variable is passed to the function. In our example, we create the "timer1" variable and set it to 1000. Later, when we set the parameter of our wait1Msec command as "timer1" the effective result is that the wait timer is set to 1000.



Before you use a motor, you must configure the NXT to access it. This brings us to our next rule:

Waddle Bot Unit 1

Waddle Bot Unit 1 Lesson 1

Functions Without Parameters

-- eraseDisplay --
  • Function Syntax: eraseDisplay()

Function Libraries

Some functions require more than one parameter. The way you can how many parameters is needed is by looking at the documentation. The first source of information is the Function Library within RobotC. This will generate when you compile a program. RobotC will also hide some of the more advanced functions from this list. To see them you need to change your menu level.

Elements of a Function

Primitive Data Types


At the most general level, everything in a program can be separated into two general groups: Commands and Data. The main difference between these groups is the ability to store information. Commands can only perform actions while data is information that can be acted upon.

The main data types that we will work with are: