Help - 'my_pwm' was not declared in this scope

I'm working on a PWM Reader and I used a existing PWM library, but it doesn't work. I got the Error Message "'my_pwm' was not declared in this scope". I'm really new to Arduino so I'll hope u guys could help me.

Header:

#ifndef PWM_h
#define PWM_h

class PWM {
    byte my_isr;

public:
    PWM(byte pin);
    
    /**
     Enables interrupt.

     @param measure_pulse_high true: High Pulse duration is measured (normal pwm), false: Low Pulse duration is measured (inverted pwm).
     
     @return 0 Success.
     @return -1 Error.
     */
    int begin(bool measure_pulse_high);
    
    /**
     Returns the most recent PWM value received.

     @return PWM duration in microseconds.
     */
    unsigned int getValue();
    
    /**
     Returns the age of recent PWM value.

     @return Age in microseconds.
     */
    unsigned long getAge();
    
    /**
     Disables interrupt.
     */
    void end();
};

#endif

CPP:

#include "Arduino.h"
#include "PWM.h"


const byte MAX_ISR_COUNT = 3;

byte isr_count = 0;
byte isr_pin[MAX_ISR_COUNT];
unsigned int isr_value[MAX_ISR_COUNT];
bool isr_last_state[MAX_ISR_COUNT];
bool isr_trigger_state[MAX_ISR_COUNT];
unsigned long isr_timer[MAX_ISR_COUNT];
unsigned long isr_age[MAX_ISR_COUNT];

void ISR_generic(byte isr) {
    unsigned long now = micros();
    bool state_now = digitalRead(isr_pin[isr]);
    if (state_now != isr_last_state[isr]) {
        if (state_now == isr_trigger_state[isr]) {
            isr_timer[isr] = now;
        } else {
            isr_value[isr] = (unsigned int)(now - isr_timer[isr]);
            isr_age[isr] = now;
        }
        isr_last_state[isr] = state_now;
    }
}

void ISR_0() {
    ISR_generic(0);
}

void ISR_1() {
    ISR_generic(1);
}

void ISR_2() {
    ISR_generic(2);
}

void ISR_3() {
    ISR_generic(3);
}

void ISR_4() {
    ISR_generic(4);
}

void ISR_5() {
    ISR_generic(5);
}

void ISR_6() {
    ISR_generic(6);
}

void ISR_7() {
    ISR_generic(7);
}

void ISR_8() {
    ISR_generic(8);
}

void ISR_9() {
    ISR_generic(9);
}

void ISR_10() {
    ISR_generic(10);
}

void ISR_11() {
    ISR_generic(11);
}

void ISR_12() {
    ISR_generic(12);
}

void ISR_13() {
    ISR_generic(13);
}

void ISR_14() {
    ISR_generic(14);
}

void ISR_15() {
    ISR_generic(15);
}

void ISR_16() {
    ISR_generic(16);
}

void ISR_17() {
    ISR_generic(17);
}

void ISR_18() {
    ISR_generic(18);
}

void ISR_19() {
    ISR_generic(19);
}

PWM::PWM(byte pin) {
    my_isr = isr_count;
    isr_count++;
    
    isr_pin[my_isr] = pin;
    pinMode(isr_pin[my_isr], INPUT);
}

int PWM::begin(bool measure_pulse_high) {
    isr_last_state[my_isr] = digitalRead(isr_pin[my_isr]);
    isr_trigger_state[my_isr] = measure_pulse_high;
    
    switch (my_isr) {
        case 0:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_0, CHANGE);
            break;
        case 1:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_1, CHANGE);
            break;
        case 2:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_2, CHANGE);
            break;
        case 3:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_3, CHANGE);
            break;
        case 4:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_4, CHANGE);
            break;
        case 5:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_5, CHANGE);
            break;
        case 6:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_6, CHANGE);
            break;
        case 7:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_7, CHANGE);
            break;
        case 8:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_8, CHANGE);
            break;
        case 9:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_9, CHANGE);
            break;
        case 10:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_10, CHANGE);
            break;
        case 11:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_11, CHANGE);
            break;
        case 12:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_12, CHANGE);
            break;
        case 13:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_13, CHANGE);
            break;
        case 14:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_14, CHANGE);
            break;
        case 15:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_15, CHANGE);
            break;
        case 16:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_16, CHANGE);
            break;
        case 17:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_17, CHANGE);
            break;
        case 18:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_18, CHANGE);
            break;
        case 19:
            attachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]), ISR_19, CHANGE);
            break;
        default:
            return -1; // Error.
    }
    return 0; // Success.
}

unsigned int PWM::getValue() {
    return isr_value[my_isr];
}

void PWM::end() {
    detachInterrupt(digitalPinToInterrupt(isr_pin[my_isr]));
}

unsigned long PWM::getAge() {
    return (micros() - isr_age[my_isr]);
}

Main Program:

#include "PWM.h"

PWM my_pwm(53);

void setup() {
    Serial.begin(115200);
    my_pwm.begin(true);
}

void loop() {
    Serial.print("Value: ");
    Serial.print(my_pwm.getValue());
    Serial.print("\tAGE: ");
    Serial.println(my_pwm.getAge());
    delay(100);
}

I got the Error Message "'my_pwm' was not declared in this scope"

The compiler told you a lot more than that.

So, I wrote my response down, and trimmed away a lot of useful information. What was left is:

You need to

PWM::PWM(byte pin) {
    my_isr = isr_count;
    isr_count++;
    
    isr_pin[my_isr] = pin;
    pinMode(isr_pin[my_isr], INPUT);
}

You can NOT use pinMode() in the constructor unless you KNOW that the constructor will only be called after init() is called.

In your sketch, that is NOT the case.