Help please with the first program!

Good day! Please help to understand with the code. There is a hall sensor and relay, trying to turn on the relay depending on the sensor readings. Found two codes and tried to combine them, the compiler gives an error: ‘PIN_RELAY’ was not declared in this scope,- at the construction site off the relay. This is my first independent program on Arduino.

#define relay_pin 6              // relay pin

int val;                                         //variable for storing the readings from the sensor
int rezult;                                     //variable of the result of comparing the reading with the zero point
int ZERO_LEVEL = 0;                    //zero level by sine wave (selected automatically after switching on, is approximately 512)
volatile int timer = 0;                    //variable for timer

ISR (TIMER0_COMPA_vect)           //function called by the counter timer every 0.001 sec
{
      timer++;                               //timer value increase by +1 every 0.001 sec
}

void setup()
{
  Serial.begin(9600);                    //serial initialization
  pinMode(relay_pin, OUTPUT);     // relay pin as output
  
  
  //Timer setting to trigger every 0.001 sec
  TCCR0A |= (1 << WGM01);
  OCR0A = 0xF9;                         //start counting until the overflow (255)
  TIMSK0 |= (1 << OCIE0A);        //Set the ISR COMPA vect
  sei();                           //allow interrupts
  TCCR0B |= (1 << CS01) | (1 << CS00); //set frequency divider to 64
  //now every 0.001 sec the function will be called ISR (TIMER0_COMPA_vect)
}

void loop()
{
  val = analogRead(0);                 //read the sensor readings
  setZeroLevel();                         //go to the function of setting the zero value of the sine wave
  if(val == ZERO_LEVEL)             //when crossing the sensor reading from the zero point
  {
      delay(5);                     //retreat from the zero point at 5 m (frequency 50Hz => the peak voltage of the sine wave will be every 5 MS)
      val = analogRead(0);           //we measure the sensor readings at the peak of the sinusoid
      if(val > ZERO_LEVEL)          //if the reading exceeds zero
      {
          rezult = val - ZERO_LEVEL;//save the result of the comparison
      }
      if(val < ZERO_LEVEL)            //if the reading is less than zero
      {    
          rezult = ZERO_LEVEL - val;//save the result of the comparison
      }
      
      Serial.println(ZERO_LEVEL);  //output the zero level
      Serial.println(rezult);            //output the value of the comparison result
      
      cli();                                    //stop interrupts
      timer = 0;                            //reset the timer variable
      sei();                                   //allow interrupts
  }        
  
  if(rezult > 5)                            //if the comparison result is greater than 5
  {
    digitalWrite(PIN_RELAY, HIGH); // Turn on the relay - send a high level of signal
  } 
  else 
  {
    digitalWrite(PIN_RELAY, LOW);  // Turn off the relay - send a low signal
  }

  
  
}

void setZeroLevel()                    //the selection function of the zero level comparison
{
  cli();                                      //stop interrupts
  int time = timer;                     //to read the value of timer
  sei();                                     //start interrupts
  if(time == 60)                        //if the timer is not reset for 60ms (and had to, because when the load is turned on, it is reset at each transition
                                               //sine wave through zero point) 
  {
    rezult = 0;                            //so we conclude that the load is turned off, but the zero point has shifted from the specified, due to inaccuracy of the hall sensor
    ZERO_LEVEL = val;               //and set a new point zero point of comparison
  }  
}

PIN_RELAY vs relay_pin ?

bit confused. Rewritten in lowercase letters, the same error

You've defined something called "relay_pin", but you're trying to use something called "PIN_RELAY"

Right, I messed up the spelling. Stupid mistake, already ashamed.(

Otherwise, the code is correct, will it work?

“Right, I messed up the spelling. Stupid mistake, already ashamed.(”

No reason to feel this way if it is the first time.

“will it work?”

You can try.