Switched to R4 Wifi and Encoder no longer works

I am currently doing a project with a stepper and an Arduino. I need an R4 for the 14 bit Analog resolution. I started with a R3 before my R4 Wifi came in and plugged everything in the same way. Now my encoder does not send signals on the Digital Pin and will not spin the stepper. If I plug the R3 back in it works perfectly. My full code is 2500 lines long and alot of it has nothing to do with the encoder. So, I have attached a bit that I used for initial testing of what is not non-functioning.

#define STEPS 400


volatile boolean TurnDetected;
volatile boolean rotationdirection;

const int PinCLK = 2;
const int PinDT = 6;
const int PinSW = 13;

const int stepPin = 8;
const int dirPin = 7;
const int enPin = 9;

int RotaryPosition = 0;

int PrevPosition;
int StepsToTake;

void isr() {
  delay(4);
  if (digitalRead(PinCLK)) {
    rotationdirection = digitalRead(PinDT);
  } else {
    rotationdirection = !digitalRead(PinDT);
  }
  TurnDetected = true;
}

void setup() {
  pinMode(PinCLK, INPUT);
  pinMode(PinDT, INPUT);
  pinMode(PinSW, INPUT);
  digitalWrite(PinSW, HIGH);
  attachInterrupt(0, isr, FALLING);
}

void loop() {
  if (!(digitalRead(PinSW))) {
    if (RotaryPosition == 0) {
    } else {
      StepsToTake = RotaryPosition;
      digitalWrite(dirPin, HIGH);
      for (int x = 0; x < StepsToTake; x++) {
        digitalWrite(stepPin, HIGH);
        delay(1);
        digitalWrite(stepPin, LOW);
        delay(1);
      }
      RotaryPosition = 0;
    }
  }

  if (TurnDetected) {
    PrevPosition = RotaryPosition;
    if (rotationdirection) {
      RotaryPosition = RotaryPosition - 1;
    } else {
      RotaryPosition = RotaryPosition + 1;
    }
  }
  TurnDetected = false;

  if ((PrevPosition + 1) == RotaryPosition) {
    StepsToTake = 40;
    digitalWrite(dirPin, HIGH);
    for (int x = 0; x < StepsToTake; x++) {
      digitalWrite(stepPin, HIGH);
      delay(1);
      digitalWrite(stepPin, LOW);
      delay(1);
    }
  }

  if ((RotaryPosition + 1) == PrevPosition) {
    StepsToTake = 40;
    digitalWrite(dirPin, LOW);
    for (int x = 0; x < StepsToTake; x++) {
      digitalWrite(stepPin, HIGH);
      delay(1);
      digitalWrite(stepPin, LOW);
      delay(1);
    }
  }
}

Welcome to the forum

Does your sketch user the Serial interface other than writing to or reading from the Serial monitor ?

No, I only use the Serial interface for debugging by writing to the monitor

This is not surprising, the Uno R4 is not the next version of the R3, but a completely different board, built on a different architecture.
If you had functions in your code that used direct access to R3 hardware (quite common for working with timers, motors, encoders), then they will not work on Uno R4

What I can see:

Having a delay in an interrupt is a quite bad idea.

The numbering pin->ISR is probably different. Use digitalPinToInterrupt() for translation.

The R4 can handle encoders in hardware. I started a library for this: