Code: const tSensors Ultrasonic = (tSensors) in1; const tSensors Ultrasonic_2 = (tSensors) in2; const tSensors Accelerometer_X = (tSensors) in3; const tSensors Accelerometer_Y = (tSensors) in4
task main() { int hold_x; //desired X-Coordinate position int hold_y; //desired Y-Coordinate position int tol = 1 ; //tolerance is 1 Inches bool tsk_done = 0; //boolean variable to keep while loop going
wait1Msec(2000); bMotorReflected[port2] = 1;
hold_x = Accelerometer_X; hold_y = Accelerometer_Y;
while (tsk_done==0) { /* Robot Moves Back if it moves away from Hold Position */ while((Accelerometer_X - hold_x) > tol || (hold_x - Accelerometer_X) > tol) { while(SensorValue(Ultrasonic) > 24) { motor[port2] = 63; motor[port3] = 63; } } while((Accelerometer_Y - hold_y) > tol || (hold_y - Accelerometer_Y) > tol) { while(SensorValue(Ultrasonic_2) > 24) { motor[port4] = 63; motor[port5] = 63; } }
//...Add Tasks to do While @ hold position } } |