Icons & Hints | Examples |
Hints: Use this command to start an inventor program when using an NXT. | This code is for the NXT. It will turn on motors A and C for 4 seconds, and then stop. |
Hints: Use this command to start an inventor program when using an NXT. | This code is for the NXT. It will turn on motors A and C for 4 seconds, and then stop. |
Hints: Use this modifier to indicate you are using the encoder in Motor A. This can only be used with the NXT motors. | This program turns on motors A and C and then waits for the NXT encoder in the motor on port A to reach 720 (2 rotations at 360 for each rotation). Then, the motors are turned off. |
Hints: Use this modifier to indicate you are using the encoder in Motor B. This can only be used with the NXT motors. | This program turns on motor B and then waits for the NXT encoder in the motor on port B to reach 720 (2 rotations at 360 for each rotation). Then, the motor is turned off. |
Hints: Use this modifier to indicate you are using the encoder in Motor C. This can only be used with the NXT motors. | This program turns on motors A and C and then waits for the NXT encoder in the motor on port C to reach 720 (2 rotations at 360 for each rotation). Then, the motors are turned off. |
Hints: ALWAYS start direct NXT programs with this command. By running in direct mode, you need to have the NXT continually connected to the computer. | This is an NXT direct code. It will turn on motors A and C and wait for the NXT touch sensor on port 4 to be pressed. After the touch sensor is pressed, the motors will be turned off. The NXT must be connected to the computer to run this code. |
Hints: Use this modifier when a sensor is connected to port 4 of the NXT. It works in the same way as the Port 1, 2, and 3 modifiers. | This program turn on motors A and C and then waits for the NXT touch sensor on port 4 to be pressed. Once the touch sensor is pressed, the motors are turned off. |
Hints: Use this modifier to get the value of a sensor connected to port 4 of the NXT. It works in the same way as the value of Port 1, 2, and 3 modifiers. | This program takes the value from the NXT light sensor on port 4 and places it in the Red Container. Then the red container is multiplied by 10 and that number is used as the frequency of a quarter note. |
Hints: Use this modifier to get the value of the angle sensor built into the NXT motor connected to port A. It works in the same way as the value of Port 1, 2, 3, and 4 modifiers. | This program is run in direct mode, so the NXT needs to be connected to the computer. This code will turn on motors A and C until the touch sensor on port 1 is pressed. Then the value of the rotation sensor built into motor A will be placed in a container and the motors will be stopped. |
Hints: Use this modifier to get the value of the angle sensor built into the NXT motor connected to port B. It works in the same way as the value of Port 1, 2, 3, and 4 modifiers. | This code will turn on motors A and C until the touch sensor on port 1 is pressed. Then the value of the rotation sensor built into motor B will be placed in a container and the motors will be stopped. |
Hints: Use this modifier to get the value of the angle sensor built into the NXT motor connected to port C. It works in the same way as the value of Port 1, 2, 3, and 4 modifiers. | This code will turn on motors A and C until the touch sensor on port 1 is pressed. Then the value of the rotation sensor built into motor C will be placed in a container and the motors will be stopped. |
Hints: This command clears the NXT display. This is useful to use before any of the other NXT display commands. | This code clears the display on the NXT and then writes Laura and Erin on row 3 and are awesome! on row 4. This will display for 2 seconds before the program ends. |
Hints: This command allows you to write text to the NXT display. To create the string to write on the NXT display, right click (control click for Mac users) on the lower right corner and choose create constant. To choose the row to display the text, right click on the lower left corner and choose create constant. Row 0 is at the top of the screen, and row 7 is at the bottom. | This code clears the display on the NXT and then writes Laura and Erin on row 3 and are awesome! on row 4. This will display for 2 seconds before the program ends. |
Hints: This command allows you to write formatted text to the NXT display. Formatted text allows you to display values of containers. To display an integer, use %d, to display a floating point number, use %f with 0. then the number of decimals to display between the % and the f. For example, %0.1f would display one number behind the decimal point. To create the string to write on the NXT display, right click (control click for Mac users) on the lower right corner and choose create constant. To choose the row to display the text, right click on the lower left corner and choose create constant. Row 0 is at the top of the screen, and row 7 is at the bottom. | This program allows your NXT to predict your lucky number! First, a random number between 0 and 8 is placed in the blue container. Then Your lucky is displayed on row 1, and number is followed by the value of the blue container on row 2. This will display for 2 seconds before the program ends. |
Hints: This command allows you to write formatted text to the NXT display, and display multiple variables. Formatted text allows you to display values of containers. To display an integer, use %d, to display a floating point number, use %f with 0. then the number of decimals to display between the % and the f. For example, %0.1f would display one number behind the decimal point. To create the string to write on the NXT display, right click (control click for Mac users) on the lower right corner and choose create constant. To choose the row to display the text, right click on the lower left corner and choose create constant. Row 0 is at the top of the screen, and row 7 is at the bottom. | This program takes the value of the NXT light sensor on port 1 and places it in the red container. The value of the NXT rotation sensor on motor A is placed in the blue container, and the value of the distance sensor on port 3 in the yellow container. These values are then displayed on row 2 on the NXT display. |
Hints: This command allows you to display a bitmap on the NXT display. To create the file path to locate the .bmp file on your computer, right click (control click for Mac users) on the lower left corner and choose create constant. If you leave the path blank, you will be able to browse for the file. | This program clears the NXT display, and then loads the bitmap file smile.bmp onto the display. This will display for 2 seconds before the program ends. |
Hints: This command allows you to draw (darken) a pixel on the NXT display. To locate the pixel, you need to give coordinates for its (x,y) position on the NXT display. The display's dimensions are 100 by 64. Position (0,0) is in the lower left corner of the NXT display. To provide the x and y locations, right click (control click for Mac users) on the lower left and right corners and choose create constant, or get numeric constants from the modifiers menu. Also, you can use the value of sensors or containers as coordinates. | This program will create a graph of light sensor data on the NXT display. First, it clears the display, empties the red container, and initializes the NXT light sensor on port 3. Next it enters a loop which draws a pixel on the NXT display with the value of the red container as the X coordinate and the value of the light sensor as the Y coordinate. It waits .05 seconds before adding one to the red container and repeating. In this way, the NXT will display a graph of the light sensor value over time (the red container acts as a counter, and allows pixels to be displayed at equal time intervals). This will display for 2 seconds before the program ends. |
Hints: This command allows you to clear (erase) a pixel on the NXT display. To locate the pixel, you need to give coordinates for its (x,y) position on the NXT display. The display's dimensions are 100 by 64. Position (0,0) is in the lower left corner of the NXT display. To provide the x and y locations, right click (control click for Mac users) on the lower left and right corners and choose create constant, or get numeric constants from the modifiers menu. Also, you can use the value of sensors or containers as coordinates. | This program will move a dot (pixel) across the NXT display. First, it makes the red container equal to 5. Next it enters a loop which draws a pixel on the NXT display with the value of the red container as the X coordinate and 30 as the Y coordinate. It waits 0.2 seconds before erasing that pixel. Then 2 is added to the red container and the loop repeats. In this way, the NXT will display a dot (pixel) moving across the display. |
Hints: This command allows you to draw a line on the NXT display. To locate the line, you need to give coordinates for the (x,y) position of its start and end point. The display's dimensions are 100 by 64. Position (0,0) is in the lower left corner of the NXT display. To provide the x and y locations, right click (control click for Mac users) on the lower left and right corners and choose create constant, or get numeric constants from the modifiers menu. Also, you can use the value of sensors or containers as coordinates. | This program will draw a diagonal line across the NXT display. First, clears the NXT display. Then it draws a line from (1,1) to (99, 60). In this way, the NXT will display a line from the lower left corner to the upper right of the NXT display. This will display for 2 seconds before the program ends. |
Hints: This command allows you to draw a rectangle on the NXT display. To locate the rectangle, you need to give coordinates for the (x,y) position of two of its corners. The display's dimensions are 100 by 64. Position (0,0) is in the lower left corner of the NXT display. To provide the x and y locations, right click (control click for Mac users) on the lower left and right corners and choose create constant, or get numeric constants from the modifiers menu. Also, you can use the value of sensors or containers as coordinates. | This program will draw a rectangle on the NXT display, and then erase half of it. First, clears the NXT display. Then it draws a rectangle that from (10,10) to (80, 50). After 2 seconds, it will erase a rectangle from (40,1) to (80,50). Then, the NXT will be displaying the left half of the rectangle (it will look like the letter C). This will display for 2 seconds before the program ends. |
Hints: This command allows you to erase a rectangle on the NXT display. To locate the rectangle, you need to give coordinates for the (x,y) position of two of its corners. The display's dimensions are 100 by 64. Position (0,0) is in the lower left corner of the NXT display. To provide the x and y locations, right click (control click for Mac users) on the lower left and right corners and choose create constant, or get numeric constants from the modifiers menu. Also, you can use the value of sensors or containers as coordinates. | This program will draw a rectangle on the NXT display, and then erase half of it. First, clears the NXT display. Then it draws a rectangle that from (10,10) to (80, 50). After 2 seconds, it will erase a rectangle from (40,1) to (80,50). Then, the NXT will be displaying the left half of the rectangle (it will look like the letter C). This will display for 2 seconds before the program ends. |
Hints: This command allows you to programmatically change views on the NXT display. The values of the NXT screens 0=standard, 1=sensor values, 2=motor speeds, 3=data log graph. To choose a view, right click (control click for Mac users) on the lower right corner and choose create constant. | This program turns on motor A at power level 3. It then switches the NXT screen to view the value of the motor speeds (and encoders). When the encoder on motor A goes above 720, then motor is turned off. |
Hints: This command allows you to play NXT sound files. To specify a file, right click (control click for Mac users) on the lower left corner and choose create constant. You can view the sound files on the NXT by choosing My files, Sound files. The file extension for NXT sound files is .rso | This program plays the NXT sound file woops.rso. |