Write a complete NQC program that spins for 2 minutes a Lego motor connected to the RCX output port B.

To write a complete NQC program that spins a Lego motor connected to the RCX output port B for 2 minutes, you can follow these steps:

Step 1: Set up the program
The first step is to set up the program by initializing the motor connected to port B. Use the `motor` command to define the motor type and port connection. In this case, you can use `motor B` to indicate that the motor is connected to port B.

```nqc
motor B
```

Step 2: Rotate the motor
To spin the motor continuously for 2 minutes, you can use a `repeat` loop. Inside the loop, use the `on` command to start the motor with a speed value.

```nqc
repeat(120)
motor B on
wait(500)
end
```

In the `repeat(120)` loop, the motor will turn on for 500 milliseconds (0.5 seconds) and then wait for the same duration before repeating the process. This will ensure that the motor spins for 2 minutes.

Step 3: Stop the motor
After the loop, you need to stop the motor. Use the `off` command to turn off the motor connected to port B.

```nqc
motor B off
```

The complete NQC program will look like this:

```nqc
motor B

repeat(120)
motor B on
wait(500)
end

motor B off
```

You can save this program with a `.nqc` extension, such as `spin_motor.nqc`, and then upload it to your RCX brick to run. Once executed, it will spin the motor connected to port B for 2 minutes.