Stuck on getting a flashing LED to stop at an off state

So, i've included a section of a larger code i'm working on, what I am trying to do it get all of my legs to flash using prevails etc which works fine, then on the press of the same IR button they switch off. What happens with this code is that they stop flashing at whatever state they are in at the time of the button press, so they stay on if they are on and off if they are off.

If I reduce the line:

digitalWrite(ledred && ledblue && ledgreen && led && leda && ledb, LOW);

to:

digitalWrite(ledred, LOW);

then they all flash and when the button is pressed with the lads on, the red turns off and the rest stay on.

if I then separate into a few lines of code like this:

digitalWrite(ledred, LOW);
digitalWrite(ledblue, LOW);
digitalWrite(ledgreen, LOW);
digitalWrite(led, LOW);

Only the red will flash the others will stay off all the time.

I am assuming that this is some sort of timing issue but I barely understand the prelims thing and timing, if someone could suggest where I am going wrong i'd appreciate it!

#include <IRremote.h>

int led = 13;
int leda = 12;
int ledb = 7; //was 11
int ledblue = 10;
int ledgreen = 9;
int ledred = 8;
int irPin = 11; //ir sensor pin
int flickstate = LOW;
long prevMillis = 0;
long interval = 300; //time between flashes

bool RedLed=false;
bool blueLed=false;
bool greenLed=false;
bool whiteLed=false;
bool flick=false;

IRrecv irrecv(irPin);
decode_results results;



// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
   irrecv.enableIRIn(); //starts IR reciever
  pinMode(led, OUTPUT); 
  pinMode(leda, OUTPUT);  
  pinMode(ledb, OUTPUT);
  pinMode(ledblue, OUTPUT);
  pinMode(ledgreen, OUTPUT);
  pinMode(ledred, OUTPUT);
}

void loop(){
  if (irrecv.decode(&results)){
    long int decCode = results.value;
    switch (results.value){

      
          case 524543: // power button
      flick=!flick;
      break; 
      
    }
     irrecv.resume();
  }
      
       if(flick)
      {
        flicker();
      }
      else
     
      digitalWrite(ledred && ledblue && ledgreen && led && leda && ledb, LOW);
      
       
        
    
     
     
        
  }
     
        void flicker()
    {
      unsigned long currentMillis = millis();
if(currentMillis - prevMillis > interval) 
  {
  prevMillis = currentMillis;
  if (flickstate == 0)
    flickstate = 1;
  else
    flickstate = 0;
  digitalWrite(ledblue, flickstate);
   digitalWrite(ledred, flickstate);
   digitalWrite(ledgreen, flickstate);
   digitalWrite(led, flickstate);
   digitalWrite(leda, flickstate);
   digitalWrite(ledb, flickstate);
  }
    }

Let's get something out of the way straight away
digitalWrite(ledred && ledblue && ledgreen && led && leda && ledb, LOW); Will not set 6 LEDs LOW. You need to set each of them LOW individually. You can do it with 6 lines of code or 3 lines of code if you know how to use arrays.

 else
    flickstate = 0;
  digitalWrite(ledblue, flickstate);
   digitalWrite(ledred, flickstate);
   digitalWrite(ledgreen, flickstate);
   digitalWrite(led, flickstate);
   digitalWrite(leda, flickstate);
   digitalWrite(ledb, flickstate);

How many of these lines did you intend to be part of the else clause? RIght now only the first is conditionally executed. The others happen every single time. Maybe you missed a couple of braces around that block.

UKHeliBob:
Will not set 6 LEDs LOW. You need to set each of them LOW individually. You can do it with 6 lines of code or 3 lines of code if you know how to use arrays.

I suppose I was clutching at straws there! I started with 6 lines of code first which results in only the first line set as low will flash and all following lines result in the related LEDs being permanently off

Delta_G:
How many of these lines did you intend to be part of the else clause? RIght now only the first is conditionally executed. The others happen every single time. Maybe you missed a couple of braces around that block.

I was trying to set flickstate = 0; only in the else statement and the rest of it to happen all the time based on what the flickstate is which sets the LEDs either on or off asked on that state, that does see to work but I still have this issue with switching them off with a button press rather than just freeze the state.

So here's the changed code for the LOW part....

What this does is ONLY flashes the red LED and the rest stay off, if I change the order of the else statement from:

else

digitalWrite(ledred, LOW);
digitalWrite(ledblue, LOW);
digitalWrite(ledgreen, LOW);
digitalWrite(led, LOW);
digitalWrite(leda, LOW);
digitalWrite(ledb, LOW);

to:

else

digitalWrite(ledblue, LOW);
digitalWrite(ledred, LOW);
digitalWrite(ledgreen, LOW);
digitalWrite(led, LOW);
digitalWrite(leda, LOW);
digitalWrite(ledb, LOW);

Then Only the blue LED will flash. Is this a timing issue? If I remove that else statement all together, I get all LEDs flashing but when the button is pressed to stop the flashing they remain in the state that they were when the button was pressed rather than turning off, so they remain off if you press the button when they are in that state and remain on if pressed when in that state.

Any suggestions?

#include <IRremote.h>

int led = 13;
int leda = 12;
int ledb = 7; //was 11
int ledblue = 10;
int ledgreen = 9;
int ledred = 8;
int irPin = 11; //ir sensor pin
int flickstate = LOW;
long prevMillis = 0;
long interval = 300; //time between flashes

bool RedLed=false;
bool blueLed=false;
bool greenLed=false;
bool whiteLed=false;
bool flick=false;

IRrecv irrecv(irPin);
decode_results results;



// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
   irrecv.enableIRIn(); //starts IR reciever
  pinMode(led, OUTPUT); 
  pinMode(leda, OUTPUT);  
  pinMode(ledb, OUTPUT);
  pinMode(ledblue, OUTPUT);
  pinMode(ledgreen, OUTPUT);
  pinMode(ledred, OUTPUT);
}

void loop(){
  if (irrecv.decode(&results)){
    long int decCode = results.value;
    switch (results.value){

      
          case 524543: // power button
      flick=!flick;
      break; 
      
    }
     irrecv.resume();
  }
      
       if(flick)
      {
        flicker();
      }
      else
     
      digitalWrite(ledred, LOW);
      digitalWrite(ledblue, LOW);
      digitalWrite(ledgreen, LOW);
      digitalWrite(led, LOW);
      digitalWrite(leda, LOW);
      digitalWrite(ledb, LOW);
      
       
        
    
     
     
        
  }
     
        void flicker()
    {
      unsigned long currentMillis = millis();
if(currentMillis - prevMillis > interval) 
  {
  prevMillis = currentMillis;
  if (flickstate == 0)
    flickstate = 1;
  else
    flickstate = 0;
    
    
  digitalWrite(ledblue, flickstate);
   digitalWrite(ledred, flickstate);
   digitalWrite(ledgreen, flickstate);
   digitalWrite(led, flickstate);
   digitalWrite(leda, flickstate);
   digitalWrite(ledb, flickstate);
  }
    }
else
     {
      digitalWrite(ledblue, LOW);
      digitalWrite(ledred, LOW);
      digitalWrite(ledgreen, LOW);
      digitalWrite(led, LOW);
      digitalWrite(leda, LOW);
      digitalWrite(ledb, LOW);
     }

As Riva has shown out you don't seem to have got the hang of how a block of code is defined.

When using a conditional such as while, if or else you want something to happen when the test returns true so the compiler needs to know what code to execute. How does it do this ? Well, it will execute the code in braces after the test as in Riva's corrected version of your code.

It is probably only fair to point out that if you only want one statement to be executed when a conditional test is true then you can leave out the braces but in my mind it is always best to use them as it makes the intentions of the statements much clearer. So much so that when I type something like

while (digitalRead(buttonPin) == HIGH)

I automatically press Return, put in a left brace, press Return twice and put in a right brace so the code looks like this

while (digitalRead(buttonPin) == HIGH)
{

}

Doing that means that I can't forget to put in the braces even if I am not sure exactly what should happen until later. It also means that even if only one statement is to be executed I cannot forget to include the braces if I later add another line of code. Another nice thing is that when the program is Auto Formatted (Ctrl/T) in the IDE the code blocks stand out.

Ah! I see, thanks UKHeliBob & Riva thats great! A very newbie error i'm sure. The code works great now with the addition of the braces!

Now I have another issue....

This code is part of a larger code which does basically the same thing except that there are other buttons involves which simply put the LEDs in an on or off state. Originally I was having issues with the flashing within that hence me separating it and now thanks to you it works, but after I re-introduce this code into the original I still cannot get the flashing to work.....

I've added the serial monitor lines to try and understand what is happening but i'm lost, when the button is pressed to execute the flicker code, the serial monitor prints "flicker" then every 1000ms prints "executing" so it's running through the code but the lights don't flash...if I had hair, id be pulling it out. Is this another newbie mistake?! I'm very pleased with how much i've learnt from these forums, there's always something new though.....

#include <IRremote.h>

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
int leda = 12;
int ledb = 7; //was 11
int ledblue = 10;
int ledgreen = 9;
int ledred = 8;
int all[] = {13, 12, 7, 10, 9, 8};
int irPin = 11; //ir sensor pin
int flickstate = LOW;
long prevMillis = 0;
long interval = 1000; //time between flashes

bool RedLed=false;
bool blueLed=false;
bool greenLed=false;
bool whiteLed=false;
bool flick=false;

IRrecv irrecv(irPin);
decode_results results;



// the setup routine runs once when you press reset:
void setup() {        
 Serial.begin(9600); //starts serial monitor *for debuging*  
  // initialize the digital pin as an output.
   irrecv.enableIRIn(); //starts IR reciever
  pinMode(led, OUTPUT); 
  pinMode(leda, OUTPUT);  
  pinMode(ledb, OUTPUT);
  pinMode(ledblue, OUTPUT);
  pinMode(ledgreen, OUTPUT);
  pinMode(ledred, OUTPUT);
}







void loop(){
  if (irrecv.decode(&results)){
    long int decCode = results.value;
    switch (results.value){

      
      case 538823: // red
       Serial.println("red");
      RedLed=!RedLed;
     break;
      
       case 555143: // blue
        Serial.println("blue");
      blueLed=!blueLed;
      break; 
      
      
      case 571463: // green
       Serial.println("green");
      greenLed=!greenLed;
      break; 
      
      
       case 546983: // white
        Serial.println("white");
      whiteLed=!whiteLed;
      break; 
      
       case 524543: // power button
        Serial.println("flicker");
      flick=!flick;
      break; 
      
      
        }
    irrecv.resume();
  }
      
      if(RedLed)
      {
       lightred();
      }
      else
      digitalWrite(ledred, LOW);
      
        if(flick)
      {
        flicker();
      }
      else
     {
      digitalWrite(ledred, LOW);
      digitalWrite(ledblue, LOW);
      digitalWrite(ledgreen, LOW);
      digitalWrite(led, LOW);
      digitalWrite(leda, LOW);
      digitalWrite(ledb, LOW);
     }
      
       if(blueLed)
      {
       lightblue();
      }
      else
      digitalWrite(ledblue, LOW);
      
       if(greenLed)
      {
       lightgreen();
      }
      else
      digitalWrite(ledgreen, LOW);
      
       if(whiteLed)
      {
       lightwhite();
      }
      else
      digitalWrite(led, LOW);
      digitalWrite(leda, LOW);
      digitalWrite(ledb, LOW);
      
      
    }
    void lightred()
    {
    digitalWrite(ledred, HIGH);
    
  }

 void lightblue()
    {
    digitalWrite(ledblue, HIGH);
    }

void lightgreen()
    {
    digitalWrite(ledgreen, HIGH);
    }
    
    
    void lightwhite()
    {
    digitalWrite(led, HIGH);
     digitalWrite(leda, HIGH);
      digitalWrite(ledb, HIGH);
    }
    
    
       void flicker()
    {
      unsigned long currentMillis = millis();
if(currentMillis - prevMillis > interval) 
  {
  prevMillis = currentMillis;
  if (flickstate == 0)
    flickstate = 1;
  else
   { flickstate = 0;
    
    
  digitalWrite(ledblue, flickstate);
   digitalWrite(ledred, flickstate);
   digitalWrite(ledgreen, flickstate);
   Serial.println("executing");
   digitalWrite(led, flickstate);
   digitalWrite(leda, flickstate);
   digitalWrite(ledb, flickstate);
  }
    }
    }

So I still have the issue but added Serial.println messages for the flickstate = 0 and =1 and in the serial monitor i get this every 1s:

executing
flickstate 0
executing
flickstate 1
executing
flickstate 0
executing
flickstate 1
executing
flickstate 0
executing
flickstate 1
executing
flickstate 0

so I can see the flick state is changing but i'm not sure why the less are not being set to that flickstate? actually from the constant current drivers I am using I can see the little indicator light for power briefly illuminate every second for a few milliseconds?!

#include <IRremote.h>

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
int leda = 12;
int ledb = 7; //was 11
int ledblue = 10;
int ledgreen = 9;
int ledred = 8;

int irPin = 11; //ir sensor pin
int flickstate = LOW;
long prevMillis = 0;
long interval = 1000; //time between flashes

bool RedLed=false;
bool blueLed=false;
bool greenLed=false;
bool whiteLed=false;
bool flick=false;

IRrecv irrecv(irPin);
decode_results results;



// the setup routine runs once when you press reset:
void setup() {        
 Serial.begin(9600); //starts serial monitor *for debuging*  
  // initialize the digital pin as an output.
   irrecv.enableIRIn(); //starts IR reciever
  pinMode(led, OUTPUT); 
  pinMode(leda, OUTPUT);  
  pinMode(ledb, OUTPUT);
  pinMode(ledblue, OUTPUT);
  pinMode(ledgreen, OUTPUT);
  pinMode(ledred, OUTPUT);
}







void loop(){
  if (irrecv.decode(&results)){
    long int decCode = results.value;
    switch (results.value){

      
      case 538823: // red
       Serial.println("red");
      RedLed=!RedLed;
     break;
      
       case 555143: // blue
        Serial.println("blue");
      blueLed=!blueLed;
      break; 
      
      
      case 571463: // green
       Serial.println("green");
      greenLed=!greenLed;
      break; 
      
      
       case 546983: // white
        Serial.println("white");
      whiteLed=!whiteLed;
      break; 
      
       case 524543: // power button
        Serial.println("flicker");
      flick=!flick;
      break; 
      
      
        }
    irrecv.resume();
  }
      
      if(RedLed)
      {
       lightred();
      }
      else
      digitalWrite(ledred, LOW);
      
        if(flick)
      {
        flicker();
      }
      else
     {
      digitalWrite(ledred, LOW);
      digitalWrite(ledblue, LOW);
      digitalWrite(ledgreen, LOW);
      digitalWrite(led, LOW);
      digitalWrite(leda, LOW);
      digitalWrite(ledb, LOW);
     }
      
       if(blueLed)
      {
       lightblue();
      }
      else
      digitalWrite(ledblue, LOW);
      
       if(greenLed)
      {
       lightgreen();
      }
      else
      digitalWrite(ledgreen, LOW);
      
       if(whiteLed)
      {
       lightwhite();
      }
      else
      digitalWrite(led, LOW);
      digitalWrite(leda, LOW);
      digitalWrite(ledb, LOW);
      
      
    }
    void lightred()
    {
    digitalWrite(ledred, HIGH);
    
  }

 void lightblue()
    {
    digitalWrite(ledblue, HIGH);
    }

void lightgreen()
    {
    digitalWrite(ledgreen, HIGH);
    }
    
    
    void lightwhite()
    {
    digitalWrite(led, HIGH);
     digitalWrite(leda, HIGH);
      digitalWrite(ledb, HIGH);
    }
    
    
       void flicker()
    {
      unsigned long currentMillis = millis();
if(currentMillis - prevMillis > interval) 
  {
  prevMillis = currentMillis;
  if (flickstate == 0)
  {
    flickstate = 1;
     Serial.println("flickstate 1");
  }
  else
  {
    flickstate = 0;
     Serial.println("flickstate 0");
  }
    
    {
  digitalWrite(ledblue, flickstate);
   digitalWrite(ledred, flickstate);
   digitalWrite(ledgreen, flickstate);
   Serial.println("executing");
   digitalWrite(led, flickstate);
   digitalWrite(leda, flickstate);
   digitalWrite(ledb, flickstate);
  }
    }
    }
 if(RedLed)
  {
    lightred();
  }
  else
    digitalWrite(ledred, LOW);

Lines line this are making the LEDs either stay on, or stay off so no wonder they won't flicker. Consider doing this

if (!flick)
{  
if(RedLed)
  {
    lightred();
  }
  else
    digitalWrite(ledred, LOW);
}

Now the LED will only change state if the flick variable is false, ie the LEDs are not blinking.

Another observation.

  if(RedLed)
  {
    lightred();
  }
  else
    digitalWrite(ledred, LOW);

could be written as

    digitalWrite(ledred, RedLed);

For sanity you might want to consider changing the names though.

However, looking further, the LEDs will not respond to the on/off commands anyway because you turn them all off each time through loop(), so change the code only do it when flickering is first turned off.

When this version is working you can tidy it up further by using arrays to hold pin numbers and LED states but get this version working first.

Wow, Thanks UKHeliBob, that's sorted it. I have edited the code as suggested which tidy things up a bit too!

What I would like to try and achieve next is to switch off any LEDs which are on when the flicker code is run, at the moment, if say the Red LED is on and the flicker code starts all the LEDs will flash but when the flicker code is stopped the red LED will remain on.

I have tried various things but am only achieving the creation of more issues!

I would also welcome advice on renaming some of these terms to make it more user friendly! I have confused myself with the names to be honest!

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
int leda = 12;
int ledb = 7; //was 11
int ledblue = 10;
int ledgreen = 9;
int ledred = 8;

int irPin = 11; //ir sensor pin
int flickstate = LOW;
long prevMillis = 0;
long interval = 1000; //time between flashes

bool RedLed=false;
bool blueLed=false;
bool greenLed=false;
bool whiteLed=false;
bool flick=false;

IRrecv irrecv(irPin);
decode_results results;



// the setup routine runs once when you press reset:
void setup() {        
 Serial.begin(9600); //starts serial monitor *for debuging*  
  // initialize the digital pin as an output.
   irrecv.enableIRIn(); //starts IR reciever
  pinMode(led, OUTPUT); 
  pinMode(leda, OUTPUT);  
  pinMode(ledb, OUTPUT);
  pinMode(ledblue, OUTPUT);
  pinMode(ledgreen, OUTPUT);
  pinMode(ledred, OUTPUT);
}







void loop(){
  if (irrecv.decode(&results)){
    long int decCode = results.value;
    switch (results.value){

      
      case 538823: // red
       Serial.println("red");
      RedLed=!RedLed;
     break;
      
       case 555143: // blue
        Serial.println("blue");
      blueLed=!blueLed;
      break; 
      
      
      case 571463: // green
       Serial.println("green");
      greenLed=!greenLed;
      break; 
      
      
       case 546983: // white
        Serial.println("white");
      whiteLed=!whiteLed;
      break; 
      
       case 524543: // power button
        Serial.println("flicker");
      flick=!flick;
      break; 
      
      
        }
    irrecv.resume();
  }
      
     if (!flick)
{  
if(RedLed)
  {
    lightred();
  }
  else
    digitalWrite(ledred, RedLed);
}

     
      
        if(flick)
      {
        flicker();
      }
   
      
      
      if (!flick)
{  
if(blueLed)
  {
    lightblue();
  }
  else
    digitalWrite(ledblue, blueLed);
}

     
     if (!flick)
{  
if(greenLed)
  {
    lightgreen();
  }
  else
    digitalWrite(ledgreen, greenLed);
}

     
    if (!flick)
{  
if(whiteLed)
  {
    lightwhite();
  }
  else
    digitalWrite(led, whiteLed);
    digitalWrite(leda, whiteLed);
    digitalWrite(ledb, whiteLed);
}

     
    
      
      
    }
    void lightred()
    {
    digitalWrite(ledred, HIGH);
    
  }

 void lightblue()
    {
    digitalWrite(ledblue, HIGH);
    }

void lightgreen()
    {
    digitalWrite(ledgreen, HIGH);
    }
    
    
    void lightwhite()
    {
    digitalWrite(led, HIGH);
     digitalWrite(leda, HIGH);
      digitalWrite(ledb, HIGH);
    }
    
    
       void flicker()
    {
      unsigned long currentMillis = millis();
if(currentMillis - prevMillis > interval) 
  {
  prevMillis = currentMillis;
  if (flickstate == 0)
  {
    flickstate = 1;
     Serial.println("flickstate 1");
  }
  else
  {
    flickstate = 0;
     Serial.println("flickstate 0");
  }
    
    
  digitalWrite(ledblue, flickstate);
   digitalWrite(ledred, flickstate);
   digitalWrite(ledgreen, flickstate);
   Serial.println("executing");
   digitalWrite(led, flickstate);
   digitalWrite(leda, flickstate);
   digitalWrite(ledb, flickstate);
 
    }
    }

OK! so i figured it out, not through knowledge but more through trial and error! I added the following into the void flicker section:

greenLed = false;
RedLed = false;
blueLed = false;
whiteLed = false;

and now they turn off when the flicker starts!

I would still appreciate some help with naming simplicity and tidying up this code a bit though please, my next aim is to have the LEDs fade through each colour but at the moment this is not possible due to the driver not supporting PWM, so i'm either going to upgrade the drivers or switch to a resistor setup, but for now i'd love to get comfortable with this code and how to make it a bit more logical!

#include <IRremote.h>

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
int leda = 12;
int ledb = 7; //was 11
int ledblue = 10;
int ledgreen = 9;
int ledred = 8;

int irPin = 11; //ir sensor pin
int flickstate = LOW;
long prevMillis = 0;
long interval = 1000; //time between flashes

bool RedLed=false;
bool blueLed=false;
bool greenLed=false;
bool whiteLed=false;
bool flick=false;

IRrecv irrecv(irPin);
decode_results results;



// the setup routine runs once when you press reset:
void setup() {        
 Serial.begin(9600); //starts serial monitor *for debuging*  
  // initialize the digital pin as an output.
   irrecv.enableIRIn(); //starts IR reciever
  pinMode(led, OUTPUT); 
  pinMode(leda, OUTPUT);  
  pinMode(ledb, OUTPUT);
  pinMode(ledblue, OUTPUT);
  pinMode(ledgreen, OUTPUT);
  pinMode(ledred, OUTPUT);
}







void loop(){
  if (irrecv.decode(&results)){
    long int decCode = results.value;
    switch (results.value){

      
      case 538823: // red
       Serial.println("red");
      RedLed=!RedLed;
     break;
      
       case 555143: // blue
        Serial.println("blue");
      blueLed=!blueLed;
      break; 
      
      
      case 571463: // green
       Serial.println("green");
      greenLed=!greenLed;
      break; 
      
      
       case 546983: // white
        Serial.println("white");
      whiteLed=!whiteLed;
      break; 
      
       case 524543: // power button
        Serial.println("flicker");
      flick=!flick;
      break; 
      
      
        }
    irrecv.resume();
  }
      
     if (!flick)
{  
if(RedLed)
  {
    lightred();
  }
  else
    digitalWrite(ledred, RedLed);
}

     
      
        if(flick)
      {
        flicker();
      }
      
      
      
      if (!flick)
{  
if(blueLed)
  {
    lightblue();
  }
  else
    digitalWrite(ledblue, blueLed);
}

     
     if (!flick)
{  
if(greenLed)
  {
    lightgreen();
  }
  else
    digitalWrite(ledgreen, greenLed);
}

     
    if (!flick)
{  
if(whiteLed)
  {
    lightwhite();
  }
  else
    digitalWrite(led, whiteLed);
    digitalWrite(leda, whiteLed);
    digitalWrite(ledb, whiteLed);
}

     
    
      
      
    }
    void lightred()
    {
    digitalWrite(ledred, HIGH);
    
  }

 void lightblue()
    {
    digitalWrite(ledblue, HIGH);
    }

void lightgreen()
    {
    digitalWrite(ledgreen, HIGH);
    }
    
    
    void lightwhite()
    {
    digitalWrite(led, HIGH);
     digitalWrite(leda, HIGH);
      digitalWrite(ledb, HIGH);
    }
    
    
       void flicker()
      
    {
      unsigned long currentMillis = millis();
if(currentMillis - prevMillis > interval) 
  {
  prevMillis = currentMillis;
  if (flickstate == 0)
  {
    flickstate = 1;
     Serial.println("flickstate 1");
  }
  else
  {
    flickstate = 0;
     Serial.println("flickstate 0");
  }
    
    greenLed = false;
    RedLed = false;
    blueLed = false;
    whiteLed = false;
    
  digitalWrite(ledblue, flickstate);
   digitalWrite(ledred, flickstate);
   digitalWrite(ledgreen, flickstate);
   Serial.println("executing");
   digitalWrite(led, flickstate);
   digitalWrite(leda, flickstate);
   digitalWrite(ledb, flickstate);
 
    }
    }

UKHeliBob:
Let's get something out of the way straight away

digitalWrite(ledred && ledblue && ledgreen && led && leda && ledb, LOW);

Will not set 6 LEDs LOW. You need to set each of them LOW individually. You can do it with 6 lines of code or 3 lines of code if you know how to use arrays.

It was a nice try though....... :slight_smile:

Well it was worth a try! Kind of a stab in the dark...