Another Programming Issue

Hey guys, sorry to bother again. Right now I am stuck in the middle of a dilemma where I cannot figure out how to let my arm position function keep my arm at a certain height during certain segments of my auton.

Here are the two functions, and I am currently trying to get it so that when my arm is up, it stays at a set height of 700 ticks of the IME, and when I want my arm down, I can just set my height variable to 0.

void auton_3(){						//Undefined
	SensorValue(claw) = 0;							//Unfold
	wait1Msec(1000);
	a_drive('f');												//forward to pick up stars
	wait1Msec(1000);
	stop();
	SensorValue(claw) = 1;							//grab stars
	a_drive('b');												//drive back
	wait1Msec(800);
	stop();
	a_drive('>');												//turn left
	wait1Msec(1000);
	stop();
	a_drive('u');												//lift arm up
	wait1Msec(1500);
	stop();
	a_drive('f');												//drive forward
	wait1Msec(1500);
	stop();
	SensorValue(claw) = 0; 							//drop stars
	a_drive('<'); 											//turn right
	wait1Msec(400);
	stop();
	a_drive('d'); 											//arm down
	wait1Msec(1000);
	stop();
	a_drive('f');											 //drive forward
	wait1Msec(500);
	stop();
	SensorValue(claw) = 1; 							//grab cube
	a_drive('<');												//turn right
	wait1Msec(200);
	stop();
	a_drive('b');												//drive back
	wait1Msec(500);
	stop();
	a_drive('u');												//lift up
	wait1Msec(1500);
	stop();
	SensorValue(claw) = 0;							//release cube
}
	void arm_pos(int height){
			if(SensorValue[IME] = height{
				motor(lift1) = 0;
				motor(lift2) = 0;
				motor(lift3) = 0;
			}
			else if(SensorValue[IME] < height{
				motor(lift1) = 127;
				motor(lift2) = 127;
				motor(lift3) = 127;
			}
			else if(SensorValue[IME] > height{
					motor(lift1) = -127;
					motor(lift2) = -127;
					motor(lift3) = -127;
			}
	}

Note: In the beginning before auton, I have my IME set to read 0 before anything occurs so that down is 0 ticks, and up is a set value of 700ish ticks.

Sorry that the comments are so messed up, just let me know if you have any questions on what any part is supposed to do. @Cody @jpearman

If I could get help tonight, that would be best, my state tournament is in a couple of days, and I need this auton to work flawlessly.

Would one way to do this is by using multitasking, or are you not able to multitask during auton. If so, how would I implement this, and how would I carry the height values over to the other task from my current task. Would it be as simple as just giving a new value to the height function, or would I have to engineer a way to carry that variable over.

By the way, I figured out that I would be able to use a potentiometer in my arm_pos function and it would just replace the IME variable already in the statement.

Yes, it sounds like you want to create an arm control task using PID, or PD or P control. Search the web/forum for proportional motor control, or PID control - there are many examples.

I understand how the P loop works, however I am having difficulty on how to implement it into my auton.

Try this forum post:
[https://vexforum.com/t/simple-p-controller-for-arm-position/23699/1)