I have what I thought was a simple task, to insert a short time delay in a signal (in this case the output from a hall sensor (signal transition every 9ms)) via the use of an interrupt and a simple loop:
for (unsigned long i = 0;i<5;i++);
attachInterrupt(3, HAInt, CHANGE);
Interestingly, no matter what number I put in the for loop (5, 50, 500, 5000, 50000, 500000) it has no effect on when the digitalWrite event occurs. Could this be because the compiler sees that the for loop does nothing and optimizes it out?
Since I can't use delay() functions in interrupts what is the proper method of inserting a time delay?