I had an idea for my sensor. Will it work?

Hi, I’ve posted some of this a few times, but I think I might be able to get it to work now. I’m using a winch system for my forklift and I’ll be using a metal sensor and 4 pieces of metallic tape on the rope for the winch to let the program know what level the forklift is on. 1st level being the ground level, and 4th level being the highest level on the rack. I was having a problem with turning the motor off at each level, but now I think i might have solved it. Any help would be appreciated ENORMOUSLY!

void Default_Routine(void)
{
 	int count = 0;
	int now;    //for mapping rc_dig_in04 to ON or OFF (sensor)
	int last; 	//for mapping rc_dig_in04 to ON or OFF (sensor)
	int now2; 	//for mapping p3_sw_trig to ON or OFF (reset p3_y)
	int last2;	//for mapping p3_sw_trig to ON or OFF (reset p3_y)
	int now3;	//for mapping p3_sw_aux1 to ON or OFF (reset counter)
	int last3;  //for mapping p3_sw_aux1 to ON or OFF (reset counter)

	now = last;
	rc_dig_in04 = now;

	last2 = now2;
	now2 = p3_sw_trig;

	last3 = now3;
	now3 = p3_sw_aux1;

then some joysticks are mapped (pwms…)
then

                  /***************
                  * Sensor Code *
                  ***************/

	
 	if((now3 == 1) && (last3 == 0)) //p3_sw_aux1 sets counter to 0 in case forklift needs to be reset.
	{
		count = 0;
	}


	if((now2 == 1) && (last2 == 0)) //p3_sw_trig sets joystick 3 y-axis to forklift motor.
	{
		pwm03 = p3_y;
	}


	if(( pwm03 < 125) || (pwm03 > 129)) //if py_3 is being used
 	{
		
		if((now == 1) && (last == 0)) //If sensor, which connects to Dig In/Out port 4, sends a signal...
		{
			count++; //Number of times tape passes through the sensor.
			Switch1_LED = 1; //Switch01 goes on when the tape passes the sensor.
		}
		else
		{
			Switch1_LED = 0;
		}
	
	
		switch(count)
		{
			case 1:			//if count == 1 then that just means that it passed through the first piece of tape which will be used to show that it is in full DOWN position.

				Relay2_green = 1;
				Relay2_red = 0;
				break;

			case 2:
		
				Relay2_green = 1;
				Relay2_red = 0;
				pwm03 != p3_y;
				pwm03 = 127; //Motor stops when it reaches 1st level of rack.
				break;
			
			case 3:
			
				Relay2_green = 1;
				Relay2_red = 0;
				pwm03 != p3_y;
				pwm03 = 127; //Motor stops when it reaches 2nd level.
				break;

			case 4:
					
				Relay2_green = 1;
				Relay2_red = 1;
				pwm03 != p3_y;
				pwm03 = 127; //Motor stops when it reaches top level.
				break;

			case 5:

				Relay2_green = 0;
				Relay2_red = 1;
				//pwm03 does not equal 127 because it must pass the tape in order to go beneath the top level.
				break;

			case 6:
			
				Relay2_green = 0;
				Relay2_red = 1;
				pwm03 != p3_y;
				pwm03 = 127; //Motor stops when it retreats to 2nd level.
				break;
			
			case 7:
			
				Relay2_green = 0;
				Relay2_red = 1;
				pwm03 != p3_y;
				pwm03 = 127; //Motor stops when it retreats to 1st level.
				break;

			case 8:
			
				Relay2_green = 0;
				Relay2_red = 0;
				pwm03 != p3_y;
				pwm03 = 127; //Motor stops when it retreats to ground level.
				count = 0;
				break;


		}
	}

You think it will work? If the sensor senses the metal, the motor will stop because it no longer is mapped to the joystick. Then if I want to keep going, I press the p3trigger button and pwm03 is remapped to the joystick because of an if statement. By the way, the relay lights just mean that if its going up, the green light is on. if its going down the red light is on. if its at the top, they are both on. Also, there are some safety measures with this, as in, since the counter counts each time the tape passes through the sensor, it must go up the whole way and down the whole way, it cannot go up to one level, then down a level, then up two…the counter will get all messy cabooy, and i haven’t had the time to figure out the code for that (i would have to include the direction of the y-axis and it’d get complicated…im new at this so imma keep this as simple as possible). So, if the driver accidentally goes down when he was supposed to go up, he would go all the way down to the bottom and then press p3_sw_aux1 which would reset the counter. Tell me if you understand any of this and let me know if you think any of this would work. I could really use the confidence.

Hey, can you please just update the thread you started before?