PWM increasing and encoder value

hi , my intention is to increase the analogWrite (PWM) value on a digital pin till the encoder value reaches to a certain limit.

if (a_read>=100 && a_read<135){ // a_read is the angle sensor value that is working as a input
analogWrite(DIRA, HIGH);
value_up==78;// at this point I want the analogWrite value to be constant as I want the motor to
keep rotating at 78 encoder value
delay(10);
}

But I guess this is not the correct way. Would really appreciate your comments on improving the code.

thanks.

I think you should use DigitalWrite instead of analogWrite.

if (a_read>=100 && a_read<135){  // a_read is the angle sensor value that is working as a input 
       analogWrite(DIRA, HIGH);
       value_up==78;// at this point I want the analogWrite value to be constant as I want the motor to
                                keep rotating at 78 encoder value     
       delay(10); 
           }

and you want that from value_up==è_ constant you should put

if (value_up ==78 )
{analogWrite(DIRA,valuethatyouwant);}

where value that you want dépends from the encoder value but it has to be between 0 to 255

actually I want a analogWrite as I will be increasing my PWM values. Again the PWM value has to start first, otherwise the motor wont rotate and I wont get any encoder value (value_up).

As I said my point is to increase the PWM value from 0 to 255 on the pin automatically to some value in between as long as the value_up=78 or some other value. Once the arduino or the corresponding pin detects that the value_up has reached to the desired value, the PWM value will be constant.

for (valoreFade = 100 ; valoreFade < 135; valoreFade++)
 {   
    analogWrite(PinPWM, valoreFade);      
   delay(10);

SOmething like this?