//Lego NXT Braitenberg Vehicle 2 code - Brian Dupuis 2008 //Plain English definitions. Note that these are arbitrary; LeftMotor may //actually be wired to the right input port. #define LeftEye S1 #define RightEye S4 #define LeftMotor OUT_B #define RightMotor OUT_C //The next two tasks run in parallel and constantly feed the values of each //eye into the respective motor as a speed. task DriveLeft(){ while(true){ OnFwd(LeftMotor, Sensor(LeftEye)); } } task DriveRight(){ while(true){ OnFwd(RightMotor, Sensor(RightEye)); } } //Main task. Turn on the eyes (but not their LEDs) and start the tasks. task main(){ SetSensorType(LeftEye, SENSOR_TYPE_LIGHT_INACTIVE); SetSensorType(RightEye, SENSOR_TYPE_LIGHT_INACTIVE); SetSensorMode(LeftEye, SENSOR_MODE_PERCENT); SetSensorMode(RightEye, SENSOR_MODE_PERCENT); start DriveLeft; start DriveRight; }