Time limit on for(int loop

mcreefer:
That delay is to set the length of time between voltage changes to the light inside a lightning strike I don't want it to effect the time limit on the loop. If I put it in the second line won't it stop the loop after the value is surpassed?

You just need another unsigned long to keep track of the last time the analog value changed:

if ( (doNothingFlag == 0) && (now - lastLightChange > interval)) {
  lightLightChange = now;
  // set interval to some random
  // analogwrite stuff
}