// Code from How Fast Does Your Arduino Code Run?
// created Steve Barth 2022.10.25.
void setup()
{
Serial.begin(115200);
pinMode(13, OUTPUT);
digitalWrite(13,LOW);
/*
unsigned long start = millis(); // micros
//*** Call to your function
//myFunction();
//delayMicroseconds(4975); // delayMicroseconds(4975) = 5000us
//delay(5000); // delay(5000) = 4999ms
//delay(5001); // delay(5001) = 5000ms
//blink(); // delay (500+500) = 999ms
loop(); // delay (500+500) = 999ms
//*** Compute the time it took
unsigned long end = millis();
unsigned long delta = end - start;
Serial.print(delta);
Serial.println(" (micros: us / millis: ms)");
*/
}
/*
void blink()
{
pinMode(13,HIGH);
delay(500);
pinMode(13,LOW);
delay(500);
}
*/
void loop()
{
unsigned long pgmStart = micros(); // micros
digitalWrite(13, HIGH);
delay(5);
digitalWrite(13, LOW);
delay(25);
unsigned long pgmEnd = micros();
unsigned long pgmTime = pgmEnd - pgmStart;
Serial.print("program time: ");
Serial.print((pgmTime/1000.)+400);
Serial.println("ms");
delay(400);
}