I want to know is it possible to execute code within C repeatly over and over for a certain amount of time (i.e how long the each traffic lights will operate for), before moving on to some other code?
Sure, just set the on/off flag for the light and then call a sleep function like sleep int unistd.h, Sleep in windows.h or delay from dos.h depending on your system for however long you need. If you ARE the system you have should have control of the embedded timing procedures. As a last resort you can build your own sleep function inside C, but it's pretty antisocial since it blocks everything on a mulitasking system. As such, I don't recommend using things like the following unless you have control and don't mind assuming that you're the most important program running.
Code:
void SLEEP(long length)
{
clock_t done = clock() + (clock_t)(length * CLOCKS_PER_SEC);
while (clock() < done)
;
}