Concept-based Lesson: concept lesson test 2

Printer-friendly version

This is an overview for this lesson


This introduction to the RobotC programming language begins to explore the basic tools and syntax. At the end of this lesson, students should be able to do the following:

  • Run and compile a simple program
  • Understand what a function is and how they work.
  • Identify the difference between strings and integers.

In all of our lessons, we will start with a sample program. It is generally a good idea to copy this program to your NXT and test it out. You can then experiment with the code and see how small changes affects your robot. Learning programming is not about doing things right the first time. It is about exploring what is possible through guided experimentation.

Let's get started with "Hello World". This program simply displays the words "Hello World" on the LCD screen.

  1. //Chapter 1 - Unit 1 - Hello World
  2. task main
  3. {
  4.   eraseDisplay(); //Clears display so we can write.
  5.   nxtDisplayString(1,"Hello World"); //Writes text to line 1
  6.   wait1Msec(2000); //Wait two seconds
  7. }