When LEGO MINDSTORMS NXT arrived, look at this web-site it brought with it a new way to program robots: NXT-G, a graphical programming environment powered by National Instruments’ LabVIEW. Instead of lines of code, NXT-G lets you build programs by dragging and connecting colorful blocks on a virtual canvas. It was designed to make robotics accessible to beginners while still offering enough depth for advanced builders. Whether you are opening NXT-G for the first time or returning to an old favorite, this guide will walk you through the workspace, essential blocks, data flow, debugging, and those clever tricks that bring your brick to life.
Getting Comfortable with the Workspace
Launch NXT-G and you will see a clean, white programming canvas taking up most of the screen. On the left sits the block palette, organized into three tabs: Common, Complete, and Custom. The Common tab holds the blocks you will use most often—Move, Sound, Display, Wait, Loop, and Switch. The Complete palette expands into every function available, from sensor blocks to math operations and file access. The Custom tab is where your own My Blocks live.
At the bottom of the window is the configuration pane. Click any block you have placed on the canvas and this pane populates with its settings: motor ports, power levels, durations, sensor thresholds, and display options. The toolbar across the top includes standard file operations, cut-and-paste tools, and the all-important controller for communicating with your NXT brick. Here you download programs, manage memory, and run the program directly from the computer with a USB cable or Bluetooth connection.
Every new program starts with a start symbol on the left edge of the canvas. Blocks connect to each other along a sequence beam, a thick gray line that dictates execution order. The NXT runs your program left to right, executing each block in turn. If you place blocks without connecting them to the main beam, they form independent sequence beams that run simultaneously—a simple way to create parallel tasks.
The Core Blocks You Need to Know
Move Block
The Move block is your robot’s legs. It controls motors connected to ports A, B, and C. In the configuration pane you choose which motors to turn, set the direction (forward, reverse, or stop), and pick a power level from 0 to 100%. You can also add steering—sliding a control left or right makes your robot turn while moving, as if one wheel is slowing down. Under Duration, you specify how far to travel: rotations, degrees, seconds, or unlimited (which means the motors keep running until stopped by another block). Want independent motor control? Switch to the “Motor” block in the Complete palette to set different speeds and directions for individual motors.
Sound Block
Robots that beep and chirp are more fun. The Sound block plays a tone (frequency and duration you set) or a pre-recorded sound file. A checkbox lets you decide whether the program waits for the sound to finish before moving to the next block—useful for creating a sequence where the robot speaks and then drives.
Display Block
The NXT’s brick LCD screen can show images, text, or simple drawings. The Display block lets you choose a file image (like a smiley face), write a line of text, or draw a circle or line. Combine it with a reset option to clear the screen before drawing something new. It’s perfect for debugging: send a sensor reading to the screen to see what your robot sees.
Wait Block
Autonomous robots don’t just drive blindly—they react to time and sensors. The Wait block pauses the program until a condition is met. Under Control you choose “Time” and set a number of seconds, or pick a sensor. For the Touch Sensor you can wait for Pressed, Released, or Bumped. The Sound Sensor waits until the noise level passes a threshold; the Light Sensor waits for light or dark; and the Ultrasonic Sensor waits until an object is closer or farther than a set distance. Every sensor-based Wait includes a feedback field so you can test the current reading right from the configuration pane before you even download the program.
Loop Block
Want to repeat an action? Drop a Loop block onto the canvas, then place the blocks you want to repeat inside its frame. In the configuration pane choose from Forever, a specific count, a sensor condition (like “until Touch Sensor pressed”), other or a logic value. Loops can be nested—for example, an outer loop runs until a clap is heard while an inner loop makes the robot drive in a square.
Switch Block
The Switch block introduces decisions. It works like an “if-else” in text-based programming. Based on a condition—a sensor value, a logic input, or a received number—it executes one of two branches of blocks. The default view shows both branches in a tabbed panel, but you can switch to a flat view where the two sequences are stacked visually. A common example: if the Touch Sensor is pressed, stop motors and back up; otherwise keep driving forward.
Data Wires: Giving Blocks a Brain
Real power comes when blocks share information. Many blocks have a data hub—a small tab at the bottom that you can click open to reveal input and output plugs. By dragging a wire from an output to an input, you pass data around.
NXT-G uses three main data types, each with its own wire color:
- Yellow wires carry numbers (sensor readings, motor degrees, math results).
- Green wires carry logic (true or false).
- Orange wires carry text (for display or file names).
Grey wires mean the data type is broken or incompatible. You fix them by checking what each plug expects. For example, the Ultrasonic Sensor block outputs a number (distance in centimeters). You could wire that number into a Math block, subtract a threshold, and feed the result into a Switch block to trigger an avoidance maneuver. Variables, accessed from the Data section of the Complete palette, allow you to store values, read them later, and pass them around your program. A Constant block lets you feed a fixed number into any input without typing it in every time.
Neat wiring is a habit worth forming. Right-click any wire and choose “Create Tunnels” to bundle connections into tidy entry and exit points that keep your canvas readable.
Working with Sensors in Real Tasks
Using sensors well transforms your robot from a remote-control toy into an autonomous machine. Here are a few patterns:
- Bump and reverse: Start motors moving forward. Place a Wait block for Touch Sensor Pressed, then a Move block that goes backwards and turns. Wrap it all in a forever Loop and you have obstacle avoidance.
- Line following: Use a Switch inside a Loop that reads the Light Sensor. If the sensor sees dark (over a line), turn one motor slightly; if light, turn the other. Adjust thresholds by calibrating from the NXT window’s live sensor feedback.
- Clap control: A Wait for Sound Sensor > 50 inside a Loop can start or stop a motor on each clap. A short Wait after triggering prevents double counts.
- Distance guard: Wait for Ultrasonic Sensor closer than 20 cm, then play a warning tone.
Don’t forget that many sensor blocks (under the Complete tab) also have a data hub that simply outputs the current reading without waiting. By feeding that value directly into math or logic, you can build more complex behaviors, like a robot that gradually slows down as it approaches a wall.
Creating Your Own Blocks with My Blocks
As your programs grow, you will find yourself repeating the same cluster of blocks. Select them, go to Edit > Make a New My Block, and give it a name—like “Turn90Right”. The environment asks you to choose icons for inputs and outputs. Now your custom block appears in the Custom palette, ready to be dropped anywhere. Need to change the behavior later? Edit the original My Block and every instance updates automatically. This is the gateway to modular, organized programming.
Downloading, Running, and Managing Memory
Connect your NXT via USB (or pair via Bluetooth) and click the download button (the arrow pointing down to the brick). The software compiles your blocks into code the brick understands and transfers the file. You can then run the program from the brick’s menu or use the “Run” button in the controller to start it immediately while still connected. The NXT window (the button that looks like the brick) shows you battery level, free memory, and all stored files. Delete old programs directly from here to free space.
Debugging Like a Pro
Even visual programs need troubleshooting. When the robot doesn’t behave, try these tactics:
- Highlight Execution: In the controller, select “Download and Run Selected” while the NXT is connected. The block currently executing will be highlighted on your screen—an excellent way to see exactly where the program gets stuck.
- Display sensor values: Use the Display block to show a number on the brick’s screen. Wire the Ultrasonic or Light Sensor output directly into the Display’s number input, and you get a live readout right on the robot.
- Check your ports: The most common mistake is configuring a motor or sensor on the wrong port. The NXT window’s live feedback panel lets you test each port interactively.
- Wait blocks inside loops: If a Loop runs without any Wait, the NXT can seem unresponsive because it cycles too fast. Always include a short Wait or a sensor condition inside your loops to give the program a manageable pace.
- Firmware: If the brick behaves oddly, re-download the firmware from the Tools menu.
A Glimpse at Advanced Tricks
Once you are comfortable, NXT-G reveals deeper possibilities. Parallel sequence beams let you monitor multiple sensors simultaneously—one beam could handle driving while another listens for a button press to stop. The File Access blocks let your robot log data to internal memory, which you can later upload and analyze. Bluetooth blocks enable communication between two NXT bricks, opening the door to cooperative robots or remote sensor arrays. And don’t overlook the Keep Alive block, which prevents the brick from turning off during long waits in a competition.
Embrace the Flow
NXT-G is much more than a beginner’s toy. Its visual nature makes the logic of programming tangible: sequences, loops, conditions, and variables are represented as shapes and colors you can physically rearrange. That clarity helps beginners learn computational thinking while giving veteran builders a rapid prototyping tool. Spend time exploring the Complete palette, right-clicking blocks for help descriptions, and experimenting with sensors. The best way to learn is to build a simple task, download it, watch what happens, and refine. Before long, the flow of blocks will feel as natural as telling a story—because that’s exactly what a program is: a set of instructions your robot follows, look at this website one block at a time.