Things You'll Need
Instructions
Build the Robot
Connect one end of a connector cable to port B of the NXT brain; connect the other end to a motor. The motors work in ports A, B or C; other sensors work in ports 1, 2, 3 or 4.
Connect a gear to the rotating end of the motor. Attach a track over the entire motor to make a tire for a tank or similar robot.
Connect the motor to the NXT brain using the Lego building pieces. Attach Lego bars and axles to the brain, and snap them into the motors to attach the brain and motors together.
Create another wheel and attach it to the other side of the NXT brain. Connect the connector cord to port C. Make sure the wheels can touch the floor without any other Lego pieces touching the floor.
Connect one end of a connector cable to port 1 of the NXT brain, and the other end to the color sensor. The color sensor is the rectangular object with a glass bulb at the end.
Connect Lego pieces to the color sensor in such a way that the front of the sensor points to the ground, with about a half-inch of space between the light bulb on the color sensor and the floor. You program this sensor to recognize the color of the floor.
Build the rest of the robot using Lego pieces. Do not make the robot too heavy, or it will not move well on the floor. Also make sure that you can press the buttons on the front of the NXT brain. Other than that, be as creative as you want.
Program the Robot
Start the Lego Mindstorms program on your computer. Select a new project.
Add a loop to the beginning of your program. The loop control will automatically snap to the front of your program's chain, which looks like a Lego bar piece. Your program will execute in sequence, starting from the first element of the chain to the last. Any controls not connected to the chain appear faded, and will not execute with your program. All subsequent controls go inside the loop to make a program that runs until you physically stop it.
Add a "Move" control to the front of your chain. This control handles the rotating motors on your robot, turning them like wheels to move your robot. By default, this control uses ports B and C. Change the "Duration" property to "Unlimited" to make the robot continuously move.
Add a "Wait Light Sensor" control to the end of the chain. Change the "Light" value from ">" (greater than) to "<" (less than). This control will cause the light sensor to continuously measure the light in front of it, waiting for a value less than 50 (the default value) to appear. When pointed at a white floor, the light sensor will make the robot will move forward while it waits to see a dark floor, at which point it will turn around.
Add another "Move" control after the wait sensor. Change the "Duration" property to "Degress" and change the number to 180. Move the "Steering" bar to the far left so the robot will make a left turn. This function only happens when the conditions of the wait sensor are met.
Connect one end of the USB cord to the computer, and the other end to your robot. Click the "Download" button to load your program onto your robot. When loading is finished, disconnect the robot from the USB cord.
Use black electrical tape to create a circle or square on a white floor. Put your robot in the designated area. Turn on the NXT brain, and press start to run the program. The robot will drive forward while the light sensor sees a white floor. When it sees a black edge, it will stop, turn around, and drive away.