One shot

I need to give a pin a one shot HIGH for 5-10 mSec in an if condition. But I need it just once -- not every time the program sees the if condition true on every scan. For instance, it would give me a 5 mSec pulse 16 million times a second. I only want it once even though the if statement stays true. I do not know how to write the code for this. Thank you for any help. Scott

Use a bool flag (maybe call it ‘pulseSent’) that’s initialized to false. Include a test for this flag being false in your ‘if’ condition. Once both conditions are satisfied, and you’ve sent your pulse, set the flag to true. The 'if' condition will never be satisfied again.

Scott_Morgan:
For instance, it would give me a 5 mSec pulse 16 million times a second.

Hardly. Something wrong with your arithmetics?

void loop() {
static bool alreadyDone = false;

  if (!alreadyDone && whateverExpression()) {
    alreadyDone = true;
    whateverFunction();
  }
}

Include a check on the state of a boolean in the conditions for triggering the pulse and only trigger if the boolean is false. When the pulse is triggered set the boolean to true to prevent further triggering