divider and analog reading

I apologize for the inexperience I have a problem the program works but only in the 1-250Hz band?

const int debounce = 2500;
const int speedometerPin = 7;
const int sensorPin = 3;
int pulseState = LOW;
volatile unsigned long currentMicros = 0;
volatile unsigned long previousMicros = 0;
volatile unsigned long currentSpeed = 0;
volatile unsigned long previousSpeed = 0;
volatile unsigned long interval = 0;
unsigned long modInterval = 0;
//float calFactor = .91;   // decrease to slow down speedometer
// calFactor of 1 makes no change to speedometer

void setup()
{
  pinMode (13, OUTPUT);
  pinMode(speedometerPin, OUTPUT);
  pinMode(sensorPin, INPUT);
  digitalWrite (sensorPin, HIGH);
  attachInterrupt (1, iSr, FALLING);
}

void loop()
{
  noInterrupts();
  modInterval = interval;
  interrupts();
  currentMicros = micros();
  if (currentMicros - previousSpeed < 1000000)
  {
    if (currentMicros - previousMicros > ((modInterval / 2) / (analogRead(A0) / 1000.0))) //calFactor))
    {
      previousMicros = currentMicros;
      if (pulseState == LOW)
        pulseState = HIGH;
      else
        pulseState = LOW;
      digitalWrite(13, pulseState);         //to blink onboard LED
      digitalWrite(speedometerPin, pulseState);
    }
  }
}

void iSr()
{
  currentSpeed = micros();
  if (digitalRead(sensorPin) == LOW)
  {
    if ((currentSpeed - previousSpeed) > debounce)
    {
      interval = currentSpeed - previousSpeed;
      previousSpeed = currentSpeed;
    }
  }
}const int debounce = 2500;
const int speedometerPin = 7;
const int sensorPin = 3;
int pulseState = LOW;
volatile unsigned long currentMicros = 0;
volatile unsigned long previousMicros = 0;
volatile unsigned long currentSpeed = 0;
volatile unsigned long previousSpeed = 0;
volatile unsigned long interval = 0;
unsigned long modInterval = 0;
//float calFactor = .91;   // decrease to slow down speedometer
// calFactor of 1 makes no change to speedometer

void setup()
{
  pinMode (13, OUTPUT);
  pinMode(speedometerPin, OUTPUT);
  pinMode(sensorPin, INPUT);
  digitalWrite (sensorPin, HIGH);
  attachInterrupt (1, iSr, FALLING);
}

void loop()
{
  noInterrupts();
  modInterval = interval;
  interrupts();
  currentMicros = micros();
  if (currentMicros - previousSpeed < 1000000)
  {
    if (currentMicros - previousMicros > ((modInterval / 2) / (analogRead(A0) / 1000.0))) //calFactor))
    {
      previousMicros = currentMicros;
      if (pulseState == LOW)
        pulseState = HIGH;
      else
        pulseState = LOW;
      digitalWrite(13, pulseState);         //to blink onboard LED
      digitalWrite(speedometerPin, pulseState);
    }
  }
}

void iSr()
{
  currentSpeed = micros();
  if (digitalRead(sensorPin) == LOW)
  {
    if ((currentSpeed - previousSpeed) > debounce)
    {
      interval = currentSpeed - previousSpeed;
      previousSpeed = currentSpeed;
    }
  }
}

(post deleted by author)

You seem to have pasted twice...

You can make this line more readable:

  attachInterrupt (1, iSr, FALLING);

  // more readable as
  attachInterrupt (digitalPinToInterrupt(sensorPin), iSr, FALLING);

and change:

void iSr()
{
  currentSpeed = micros();
  if (digitalRead(sensorPin) == LOW)
  {
    if ((currentSpeed - previousSpeed) > debounce)
    {
      interval = currentSpeed - previousSpeed;
      previousSpeed = currentSpeed;
    }
  }
}

to

void iSr()
{
  currentSpeed = micros();
  if ((currentSpeed - previousSpeed) > debounce)
  {
    interval = currentSpeed - previousSpeed;
    previousSpeed = currentSpeed;
  }
}

since its only triggered by the falling sensorPin, no point reading it.

You have correctly accessed interval in a critical section in loop() (i.e. using noInterrupts()), but forgot to
do the same for previousSpeed...

You need to be more explicit about what you expect it to do and what its actually doing...

You are reading previousSpeed without making a copy when interrupts are disabled.

I did the suggested changes however it behaves the same 1-250Hz works fine over it no?

const int debounce = 2500;
const int speedometerPin = 7;
const int sensorPin = 3;
int pulseState = LOW;
volatile unsigned long currentMicros = 0;
volatile unsigned long previousMicros = 0;
volatile unsigned long currentSpeed = 0;
volatile unsigned long previousSpeed = 0;
volatile unsigned long interval = 0;
unsigned long modInterval = 0;
//float calFactor = .91;   // decrease to slow down speedometer
// calFactor of 1 makes no change to speedometer

void setup()
{
  pinMode (13, OUTPUT);
  pinMode(speedometerPin, OUTPUT);
  pinMode(sensorPin, INPUT);
  digitalWrite (sensorPin, HIGH);
  attachInterrupt (1, iSr, FALLING);
}

void loop()
{
  noInterrupts();
  modInterval = interval;
  interrupts();
  currentMicros = micros();
  if (currentMicros - previousSpeed < 1000000)
  {
    if (currentMicros - previousMicros > ((modInterval / 2) / (analogRead(A0) / 1000.0))) //calFactor))
    {
      previousMicros = currentMicros;
      if (pulseState == LOW)
        pulseState = HIGH;
      else
        pulseState = LOW;
      digitalWrite(13, pulseState);         //to blink onboard LED
      digitalWrite(speedometerPin, pulseState);
    }
  }
}


void iSr()
{
  currentSpeed = micros();
  if ((currentSpeed - previousSpeed) > debounce)
  {
    interval = currentSpeed - previousSpeed;
    previousSpeed = currentSpeed;
  }
}