8 led turn on individual.

I'm newbew.i have 8 led.turn it on one by one and again.every led have their own interval.but do not use the delay function.that one,i have done and succesfull.now iwanna change it into more precise timing,i wanna using millis function.so i start from the sketch from "blink led without delay".after copy paste the sketch,it very confusing me to add 8 led with this sketch.

Post the code you have written so far.

If after a period ( full stop ) you put a space and then a capital letter it will make your post so much easer to read.

Opp…Sorry.This is my sketch.I wan to switch on the 8 channel relay one by one with differen interval.

unsigned long previousMillisLED13.pdf (115 KB)

unsigned long previousMillisLED13 = 0;
unsigned long previousMillisLED12 = 0;
unsigned long previousMillisLED11 = 0;
unsigned long previousMillisLED10 = 0;
unsigned long previousMillisLED9 = 0;
unsigned long previousMillisLED8 = 0;
unsigned long previousMillisLED7 = 0;
unsigned long previousMillisLED6 = 0;
unsigned long currentMillis = 0;
int intervalLED13 = 1000; int intervalLED12 = 1000;int intervalLED11 = 1000;int intervalLED10 = 1000;int intervalLED9 = 1000;int intervalLED8 = 1000;int
intervalLED7 = 1000;int intervalLED6 = 1000;
boolean LED13state = false;
boolean LED12state = false;
boolean LED11state = false;
boolean LED10state = false;
boolean LED9state = false;
boolean LED8state = false;
boolean LED7state = false;
boolean LED6state = false;
void setup() {
pinMode(13, OUTPUT); pinMode(12, OUTPUT); pinMode(11, OUTPUT); pinMode(10, OUTPUT); pinMode(9, OUTPUT); pinMode(8, OUTPUT);
pinMode(7, OUTPUT); pinMode(6, OUTPUT);
}
void loop()
{
currentMillis = millis();
if( currentMillis - previousMillisLED13 >=intervalLED13)
{
LED13state = !LED13state;
digitalWrite(13,LED13state);
previousMillisLED13 = currentMillis ;
}
if( currentMillis - previousMillisLED12 >=intervalLED12)
{
LED12state = !LED12state;
digitalWrite(12,LED12state);
previousMillisLED12 = currentMillis ;
}
if( currentMillis - previousMillisLED11 >=intervalLED11)
{
LED11state = !LED11state;
digitalWrite(11,LED11state);
previousMillisLED11 = currentMillis ;
}
if( currentMillis - previousMillisLED10 >=intervalLED10)
{
LED10state = !LED10state;
digitalWrite(10,LED10state);
previousMillisLED10 = currentMillis ;
}
if( currentMillis - previousMillisLED9 >=intervalLED9)
{
LED9state = !LED9state;
digitalWrite(9,LED9state);
previousMillisLED9 = currentMillis ;
}
if( currentMillis - previousMillisLED8 >=intervalLED8)
{
LED8state = !LED8state;
digitalWrite(8,LED8state);
previousMillisLED8 = currentMillis ;
}
if( currentMillis - previousMillisLED7 >=intervalLED7)
{
LED7state = !LED7state;
digitalWrite(7,LED7state);
previousMillisLED7 = currentMillis ;
}
if( currentMillis - previousMillisLED6 >=intervalLED6)
{
LED6state = !LED6state;
digitalWrite(6,LED6state);
previousMillisLED6 = currentMillis ;

You are setting all the time intervals to the same value so they will all turn in and off at the same time.

What is the problem you are having with this sketch?

It will be a hell of a lot shorter if you learn to use arrays

Edit - for God's sake man use code tags.

It working. But not as i wan,turn on the led one by one. I now the interval is same.
The led running from 13 to 6, again and again. Mybe same like running light led.

intervalLED13 = 10000;
intervalLED12 = 3000;
intervalLED11 = 10000;
intervalLED10 = 3000;
intervalLED9 = 10000;
intervalLED8 = 3000;
intervalLED7 = 10000;
intervalLED6 = 3000;

Well you now have two different intervals. Make each interval different.

What do you mean by turn on one by one. That code turns on and off at fixed intervals.

Right, first things first.

Go and read the instructions, then go back and modify each of your posts (use the "More --> Modify" option to the bottom right of the post) to mark up the code as such so we can examine it conveniently and accurately.

If you do not do this, the code you post could well be garbled.

Note: Also mark up any data in the same way. This includes error output that you get from the IDE.

And while you are at it, you can remove the post with the .pdf version of the code - a .pdf is quite useless as it is a file format which obscures data.

Even better, re-post the code after you use "Auto-Format" (under "Tools" in the menu or simply Control-T) to clean it up.

Until you reply and demonstrate that you understand these points that have been made so far, there is pretty much no point working through the other problems with the code, so I will leave it at that for the present.