Adding array of LED into a FOR controlled 7 segment loop.

Hello. I am very new to arduino c programming and any help is very much appreciated.
I am doing this project in school where we are to create an advertisement board with 4 7-segment displays and 8 LEDs.
I used four 595 shift registered cascaded together to control the 7-segents, through a bunch of sequences, making it look like running text.
When i started working on the addition of the 8 LEDs however, i experienced a problem:
I cant seem to bypass the 7-Segment FOR loop and force LEDs to be on their own so to speak. Either the LEDS have to be inside of my FOR loop through normal digitalWrite(HIGH/LOW) but then they run with the same frequency as the shiftOut(), or, if I create another FOR loop with array for LEDs, they take over, and shifting does not happen.

What i want is LEDs to be running back and forth while the 7-segments are doing their own thing through my 595's.

Any suggestions are welcome!
I am uploding the code that i have per today, where LEDs are running synchronized with shiftOUT.

Thank you.

int ser=13;
int clk=3;
int latch=4;
int led1 = 2;
int led2 = 5;
int led3 = 6;
int led4 = 7;
int led5 = 9;
int led6 = 10;
int led7 = 11;
int led8 = 12;
int sekv[24] = {62,95,3,99,115,1,95,119,62,0,62,0,62,0,62,0,115,0,115,0,115,0,115,0};
int sekv1[24] = {95,3,99,115,1,95,119,62,95,0,95,0,95,0,95,0,1,0,1,0,1,0,1,0};
int sekv2[24] = {3,99,115,1,95,119,62,95,3,0,3,0,3,0,3,0,95,0,95,0,95,0,95,0};
int sekv3[24] = {99,115,1,95,119,62,95,3,99,0,99,0,99,0,99,0,119,0,119,0,119,0,119,0};

void setup() {
// put your setup code here, to run once:
pinMode(ser, OUTPUT);
pinMode(clk, OUTPUT);
pinMode(latch, OUTPUT);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
pinMode(led8, OUTPUT);

}

void loop()

{ for (int i = 0; i < 24; i++)
{

digitalWrite (led1, HIGH);
delay (50);
digitalWrite (led1, LOW);
digitalWrite (led2, HIGH);
delay (50);
digitalWrite (led2, LOW);
digitalWrite (led3, HIGH);
delay (50);
digitalWrite (led3, LOW);
digitalWrite (led4, HIGH);
delay (50);
digitalWrite (led4, LOW);
delay (50);
digitalWrite (led5, HIGH);
delay (50);
digitalWrite (led5, LOW);
digitalWrite (led6, HIGH);
delay (50);
digitalWrite (led6, LOW);
digitalWrite (led7, HIGH);
delay (50);
digitalWrite (led7, LOW);
digitalWrite (led8, HIGH);
delay (50);
digitalWrite (led8, LOW);
digitalWrite(latch, LOW);
shiftOut(ser, clk, LSBFIRST, sekv3*);*
shiftOut(ser, clk, LSBFIRST, sekv2*);*
shiftOut(ser, clk, LSBFIRST, sekv1*);*
shiftOut(ser, clk, LSBFIRST, sekv*);*
delay(400);
digitalWrite(latch, HIGH);
}
}
prosjekta.ino (1.74 KB)

int sekv[24] = {62,95,3,99,115,1,95,119,62,0,62,0,62,0,62,0,115,0,115,0,115,0,115,0};
int sekv1[24] = {95,3,99,115,1,95,119,62,95,0,95,0,95,0,95,0,1,0,1,0,1,0,1,0};
int sekv2[24] = {3,99,115,1,95,119,62,95,3,0,3,0,3,0,3,0,95,0,95,0,95,0,95,0};
int sekv3[24] = {99,115,1,95,119,62,95,3,99,0,99,0,99,0,99,0,119,0,119,0,119,0,119,0};

All the values would fit in byte arrays. Why are you wasting 96 bytes of SRAM?

The loop() function is called over and over. Get rid of the for loop in loop. On each pass through loop, simply increment the value of the static or global variable i (and I'll personally come kick your ass if you make it global), do whatever you need to for that value of i, and then determine whether to reset it to -1.

Independently, decide if it is time to diddle with any LED, using the blink without delay example as a guide, and get rid of ALL of the delay() calls.

Hi. Thank you for the response, I'll try to make sense of your suggestions, but like I said, it's my second week with arduino, and I base a lot of what I do on what I can google. Unfortunately I've yet to see a single example of array shiftout without using a FOR loop. But indeed, I would very much like to not have to use it! You are ofcours correct about my wrong usage of data types, and I will change them to bytes, but there is no reason I used INT really, I'm just used to it, from previous times I worked with ide. But I promise you, I'll pay more attention to it: )

Unfortunately I've yet to see a single example of array shiftout without using a FOR loop.

Well, since you failed to post your code correctly, it's hard to see exactly what is being shifted out. The for loop to shift out data may be necessary, but, clearly, taking almost a second per iteration of the for loop is not cutting it.

Magic numbers in the for loop don't, either. Replace the 24 with something like this:

#define NotAMagicNumber 24

and

for(byte i=0; i<NotAMagicNumber; i++)
{
}

(Only, use a meaningful name.)

Then, we'd be able to see why you loop the number of times you do.

And, read the stickies at the top of the forum before you post any more code.

hiost:
When i started working on the addition of the 8 LEDs however, i experienced a problem:

From this I assume your shifting was working OK before the addition of the LEDS?

hiost:
I cant seem to bypass the 7-Segment FOR loop and force LEDs to be on their own so to speak. Either the LEDS have to be inside of my FOR loop through normal digitalWrite(HIGH/LOW) but then they run with the same frequency as the shiftOut(), or, if I create another FOR loop with array for LEDs, they take over, and shifting does not happen.

From this I assume that your LED timing wants to be independent of your shifting opperation?

hiost:
What i want is LEDs to be running back and forth

I assume you mean Knight Rider style kinda thing.

I've done a bit of tinkering with your original sketch and come up with the following. I have no way of testing it, however, so it may take a bit of debugging.

int ser=13;
int clk=3;
int latch=4;
int button = 8;
int State = LOW;
int LEDS[8]={
  2,5,6,7,9,10,11,12};
int sekv[24] = {
  62,95,3,99,115,1,95,119,62,0,62,0,62,0,62,0,115,0,115,0,115,0,115,0};
int sekv1[24] = {
  95,3,99,115,1,95,119,62,95,0,95,0,95,0,95,0,1,0,1,0,1,0,1,0};
int sekv2[24] = {
  3,99,115,1,95,119,62,95,3,0,3,0,3,0,3,0,95,0,95,0,95,0,95,0};
int sekv3[24] = {
  99,115,1,95,119,62,95,3,99,0,99,0,99,0,99,0,119,0,119,0,119,0,119,0};

void setup() {
  // put your setup code here, to run once:
  pinMode(ser, OUTPUT); //seriel utgang fra arduino til shiftregister
  pinMode(clk, OUTPUT); //klokke signal
  pinMode(latch, OUTPUT); //"av/på" bryter for shiftregistere
  pinMode(button, INPUT);
  for(int n=0;n<9;n++)
    pinMode(LEDS[n],OUTPUT);
}

int oldForLoopCounter=0;

unsigned long lastShift=0;
void loop() 
{
  unsigned long t = millis();

  serviceLeds();

  if ((t-lastShift)>500)
  {
    digitalWrite(latch, LOW);
    shiftOut(ser, clk, LSBFIRST, sekv3[oldForLoopCounter]);
    shiftOut(ser, clk, LSBFIRST, sekv2[oldForLoopCounter]);
    shiftOut(ser, clk, LSBFIRST, sekv1[oldForLoopCounter]);
    shiftOut(ser, clk, LSBFIRST, sekv[oldForLoopCounter]);
    //delay(500);//now redundant 
    digitalWrite(latch, HIGH);

    //update counter for next time through the loop
    oldForLoopCounter++;
    if(oldForLoopCounter>23)
      oldForLoopCounter=0;
    //and the time we just shifted
    lastShift=t;
  }
}

void serviceLeds()
{
  //assuming led sequence required is 
  //0,1,2,3,4,5,6,7,6,5,4,3,2,1,and repeat

  unsigned long t = millis() %700;
  int activeLed=t/50;  //should produce 0 to 13 inclusive 
  if (activeLed>7)
    activeLed=14-activeLed; //convert values of 8-13 to be 6-1

  //Now set ALL leds to their appropriate states
  for (int n=0;n<8;n++)
  {
    if(n==activeLed)
      digitalWrite(LEDS[n],HIGH);
    else
      digitalWrite(LEDS[n],LOW);
  } 
}

Thanks for all the replies! Tommorow when i get my hands on my equipment again, ill will try to see whats what in your guys suggestions!