I thought I had the Millis() command sorted but i'm stumped on the one. Aim is to get 2 led's alternately dimming, they work great with delay(); of course....but i can't figure where i'm going wrong with Millis(). Please have a look and point out what i've got wrong. Thanks Doug
int LED3 = 5; int LED4 = 6;
// each "event" (LED) gets their own tracking variable unsigned long previousMillisLED3=0; unsigned long previousMillisLED4=0;
int intervalLED3 = 500; int intervalLED4 = 500;
void setup() { pinMode(LED3, OUTPUT); pinMode(LED4, OUTPUT);
int LED3 = 5;
int LED4 = 6;
// each "event" (LED) gets their own tracking variable
unsigned long previousMillisLED3=0;
unsigned long previousMillisLED4=0;
int intervalLED3 = 500;
int intervalLED4 = 500;
void setup() {
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
}
void loop() {
//unsigned long currentMillis = millis();
for(int P=0;P<6;P++){
//if ((unsigned long)(currentMillis - previousMillisLED3) >= intervalLED3) {
analogWrite(LED3, 127);
analogWrite(LED4, 254);
delay(500);
//previousMillisLED3 = currentMillis;
}
void loop() {
//unsigned long currentMillis = millis();
for(int P=0;P<6;P++){
//if ((unsigned long)(currentMillis - previousMillisLED3) >= intervalLED3) {
analogWrite(LED3, 127);
analogWrite(LED4, 254);
delay(500);
//previousMillisLED3 = currentMillis;
//if ((unsigned long)(currentMillis - previousMillisLED4) >= intervalLED4) {
analogWrite(LED3, 254);
analogWrite(LED4, 127);
delay(500);
//previousMillisLED4 = currentMillis;
}
}
}
Sorry, problems inputting code, but its all there.
I realize that there are some closing brackets missing in the LOOP() section for millis but it is set for delay() to show that it works.