loop speed control

hey, im a relative newb to this (4months) so ive been looking for a way to control how often the "void loop" section is executed. i know that as standard it is done as fat as possible but i wanted to set it to only activate once every set amount of milliseconds. can this be done? if not can it be done for individual commands and how so? thanks in advance guys

See Examples->Basics->Blink and Examples->Digital->BlinkWithoutDelay

PSEUDOCODE

void loop() {
  //take note of time before
  //do your thing
  //timeSpent = currentTime - before
  //if timeSpent is not enough , simply wait before returning
  //  delay(timeToSpend-timeSpent); //if you need 50 times a second you'll need timeToSpend = 1000 / 50;
}

thanks guys :grin: