 }
 
 // Control a run
-void run(int predelay, int stepdelay, int exposureduration, int postexposure)
+void run(int predelay, int stimdelay, int shutterdelay, int stepdelay, int exposureduration, int postexposure)
 {
     delay(predelay);
+    digitalWrite(STIM_OUT, HIGH);
+    digitalWrite(STIM_LED, HIGH);
+    delay(stimdelay);
     digitalWrite(SHUT_OUT, HIGH); // shutter opened before step delay
     digitalWrite(SHUT_LED, HIGH); // may open during pre-delay in future
+    delay(shutterdelay);
     digitalWrite(LEN_OUT, HIGH);
     digitalWrite(LEN_LED, HIGH);
     delayMicroseconds(stepdelay);
     digitalWrite(EXPOSE_OUT, HIGH);
     digitalWrite(EXPOSE_LED, HIGH);
     delayMicroseconds(exposureduration);
+    digitalWrite(STIM_OUT, LOW);
+    digitalWrite(STIM_LED, LOW);
     digitalWrite(EXPOSE_OUT, LOW);
     digitalWrite(EXPOSE_LED, LOW);
     digitalWrite(SHUT_OUT, LOW);

int SHUT_LED   = 5;
int EXPOSE_OUT = 6; // to exposure trigger
int EXPOSE_LED = 7;

// Begin setup of board
void setup()



// Timing variables
const int PREDELAY  = 10;     // in ms
const int STIMDELAY = 200;    // in ms
const int SHUTTERDELAY = 3;   // in ms
const int STEPDELAY = 200;    // in µs
const int EXPOSUREDUR = 500;  // in µs
const int POSTEXPOSURE = 100; // in ms

// Non-global variable declaration
