# I have doubt in C

Can anyone tell me what is more fast for ardunio execute, this is for turn on/off leds:

for(i=0; i<7; i++){
if(ABC == 1)
_ digitalWrite(Lar*, HIGH);_
_ digitalWrite(Lar, LOW);
}
[/quote]
or
> if(ABC[0] == 1)
> digitalWrite(Lar[0], HIGH);
> if(ABC[1] == 1)
> digitalWrite(Lar[1], HIGH);
> if(ABC[2] == 1)
> digitalWrite(Lar[2], HIGH);
> if(ABC[l][j][3] == 1)
> digitalWrite(Lar[3], HIGH);
> if(ABC[4] == 1)
> digitalWrite(Lar[4], HIGH);
> if(ABC[5] == 1)
> digitalWrite(Lar[5], HIGH);
> if(ABC[6] == 1)
> digitalWrite(Lar[6], HIGH);
> digitalWrite(Lar[0], LOW);
> digitalWrite(Lar[1], LOW);
> digitalWrite(Lar[2], LOW);
> digitalWrite(Lar[3], LOW);
> digitalWrite(Lar[4], LOW);
> digitalWrite(Lar[5], LOW);
> digitalWrite(Lar[6], LOW);*_

What exactly are you trying to achieve here? By unrolling the loop the code will execute slightly faster but for what your code is doing, this speedup will be insignificant.

If you are doing nothing between turning the LED on and turning it off, there is no reason to even turn it on. Might just as well skip the loop altogether.

Also, since HIGH == 1, you could replace:

``````if(ABC[i] == 1)
digitalWrite(Lar[i], HIGH);
``````

with:

``````  digitalWrite(Lar[i], ABC[i]);
``````

(presuming that the alternate value in ABC is 0, of course.)

thank i didn't know that i can use 1=High and 0=Low,

this is just a pice of my code to croll letters to a 7x2