Calculating trigger points

Can someone please help me with code? I have a 24 tooth trigger wheel. Every tooth is registered by hall sensor and I need that Arduino simulate 36 pulse output of that corresponding 24 pulse input.

Here is my code with delayMicroseconds, but I can`t use delayMicroseconds, because Arduino doesn't understand bigger than 16k micros delay.

const int  hall = 2;    // hall sensor
const int ledPin = 13;       // the pin that the LED is attached to

// Variables will change:
int teethCounter = 0;
int hallState = 0;
int lasthallState = 0;
long cycles=0;
boolean cycle = false;
unsigned long microsStart = 0;
unsigned long microsStop = 0;
unsigned long usElapsed = 0;
unsigned long usElapsedUp = 0;
unsigned long usInterval;


void setup() {
// initialize the button pin as a input:
pinMode(hall, INPUT);
// initialize the LED as an output:
pinMode(ledPin, OUTPUT);
// initialize serial communication:
Serial.begin(9600);
}


void loop() {
hallState = digitalRead(hall);
if(cycle==true){
microsStart=micros();
}
if(cycle==true){
usInterval = usElapsedUp/72;
for (int i=0; i <= 36; i++){
digitalWrite(13,HIGH);
delayMicroseconds(usInterval);
digitalWrite(13,LOW);
delayMicroseconds(usInterval);
cycle = false;
}
}

// compare the hallState to its previous state
if (hallState != lasthallState) {
// if the state has changed, increment the counter
if (hallState == HIGH) {
  teethCounter++;
  if(teethCounter==24){
    cycle = true;
    cycles++;
    teethCounter=0;
    usElapsedUp = usElapsed;

  }

  Serial.print("Tooth count: ");
  Serial.print(teethCounter);
  Serial.print(" Cycles: ");
  Serial.print(cycles);
  Serial.print(" Time: ");
  Serial.print(usElapsedUp);
  Serial.print(" Interval: ");
  Serial.println(usInterval);
  }
   microsStop=micros();
   usElapsed=microsStop-microsStart;
  }
 // save the current state as the last state,
 //for next time through the loop

   lasthallState = hallState;
   }

How can I calculate and from where can I take trigger points?

If(event happens==true){
digitalWrite(13,HIGH);
}
If(event happens==false){
digitalWrite(13,LOW);
}

but I can`t use delayMicroseconds, because Arduino doesn't understand bigger than 16k micros delay.

If you need to delay longer than a few microseconds, delayMicroseconds() is not the right function. delay() deals in milliseconds (which is what thousands of microseconds are).

PaulS:
If you need to delay longer than a few microseconds, delayMicroseconds() is not the right function. delay() deals in milliseconds (which is what thousands of microseconds are).

Because trigger wheel spins anywhere from 0 RPM up to 6000 RPM. And with my code where time is used it will not count realtime, there will be always 1 rpm error.

Because trigger wheel spins anywhere from 0 RPM up to 6000 RPM.

So, 0 to 100 Hz. Does that put things in context?

So, you need 3 pulses out for every 2 pulses from the Hall sensor. Similar to frequency conversion with a fractional PLL. And like a PLL, a lot depends on how much error and jitter (phase noise) you're willing to put up with.

The code below is untested, but it does compile. There is no jitter filtering and it doesn't check for 0 RPM. That's an exercise for the reader. But, give it a try. If you need more accuracy or less jitter, you'll have to add filtering and go to more sophisticated techniques such as timer interrupts and direct port access.

const uint8_t  hall = 2;
const uint8_t ledPin = 13;
const double timeRatio = 2.0 / 6.0;

uint32_t pulseTime, pulseInterval, risingEdgeTime, currentMicros;
uint8_t lastHall, pulseOut;

void setup() {
  Serial.begin(9600);

  pulseOut = LOW;
  digitalWrite(ledPin,LOW);
  
  // measure a clean rising edge to rising edge interval
  while (digitalRead(hall)) {}  // wait for falling edge
  while (!digitalRead(hall)) {}  // wait for rising edge
  risingEdgeTime = micros();
  while (digitalRead(hall)) {}  // wait for falling edge
  while (!digitalRead(hall)) {}  // wait for rising edge
  currentMicros = micros();  
  pulseInterval = (risingEdgeTime - currentMicros) * timeRatio;
  risingEdgeTime = currentMicros;  
  pulseTime = currentMicros;
  lastHall = 1;
}

void loop() {
  uint8_t currentHall;
  
  currentMicros = micros();
  if (currentMicros-pulseTime >= pulseInterval) {
    pulseTime += pulseInterval;
    switch (pulseOut) {
      case HIGH:
        digitalWrite(ledPin,LOW);
        pulseOut = LOW;
        break;
      case LOW:
        digitalWrite(ledPin,HIGH);
        pulseOut = HIGH;
        break;
      default:
        break;
    }

    if ((currentHall=digitalRead(hall)) != lastHall) {
      currentMicros = micros();
      if (currentHall) {
        pulseInterval = (risingEdgeTime - currentMicros) * timeRatio;
        risingEdgeTime = currentMicros;        
      }
      lastHall = currentHall;
    }
  }
}