NOTE: When
beginning to program in NQC, it is extremely helpful to start with one simple
task, function, or sub. Once it is working, add more code or move on. The
following programs are my NQC learning progression. The robot designs are from
"The Definitive Guide to Lego Mindstorms" by Dave Baum.
// OUT THE
DOOR---- 'Tankbot' design. two motors. This program sends the Robot // out of
my room and //down the hall. It only uses 1 main task
// motors-
Renames the drive motors LEFT & RIGHT
#define LEFT OUT_A
#define RIGHT OUT_C
// other
constants- sets constant values (in seconds X 100) for turning, //reversing and
running straight down the hall
#define
STRAIT_AWAY 2200 //22 seconds
#define
TURN_TIME 150 //1 1/2 second
#define REV_TIME 50
//1/2 second
task main()
{
On(LEFT+RIGHT); //Turns both motors on
Wait(450); //Runs for 4.5 seconds
Rev(LEFT); //left motor runs backwards…
Wait(TURN_TIME); //for 1.5 seconds
Fwd(LEFT); //left motor runs forward
Wait(STRAIT_AWAY); //runs forward for 22 seconds
Rev(LEFT); //left motor runs backwards…
Wait(TURN_TIME+TURN_TIME); //for 3 seconds(chair + corner in way)
Fwd(LEFT); //left motor runs forward
Wait(STRAIT_AWAY); //runs forward for 22 seconds
}//main