Flashing LED Light Issue

Hi Arduino Geniuses

I have a project that is fairly basic. Press a button, lights on an led strip come on, press it again, different lights come on. A have various buttons and various LED strips. The code "works" but the issue I'm having is that the LED's are flashing rapidly when they come on. Any help would be appreciated.

#include <FastLED.h>
#define LED_PIN 2
#define TENhomesss_PIN 3
#define AWAYONES_PIN 4
#define AWAYTENS_PIN 5
#define BALLS_PIN 6
#define STRIKES_PIN 7
#define OUTS_PIN 8
#define NUM_LEDS 60
#define Delay 500
#define Color1 Blue;

CRGB homesss[NUM_LEDS];
CRGB leds[NUM_LEDS];
CRGB awayones[NUM_LEDS];
CRGB awaytens[NUM_LEDS];
CRGB balls[NUM_LEDS];
CRGB strikes[NUM_LEDS];
CRGB outs[NUM_LEDS];
int lastState = HIGH; // the previous state from the input pin
int ballslastState = HIGH;
int strikeslastState = HIGH;
int outslastState = HIGH;
int currentState; 
int ballscurrentState;
int strikescurrentState;
int outscurrentState;
int awaylastState = HIGH; // the previous state from the input pin
int awaycurrentState; 
int count = 0;
int tencount = 0;
int awaycount = 0;
int awaytencount = 0;
int ballscount = 0;
int strikescount = 0;
int outscount = 0;
const int BUTTON_PIN = 9;
const int AWAYBUTTON_PIN = 10;
const int BALLSBUTTON_PIN = 11;
const int STRIKESBUTTON_PIN = 12;
const int OUTSBUTTON_PIN = 13;

void setup() {
  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
   FastLED.addLeds<WS2812, TENhomesss_PIN, GRB>(homesss, NUM_LEDS);
   FastLED.addLeds<WS2812, AWAYONES_PIN, GRB>(awayones, NUM_LEDS);
   FastLED.addLeds<WS2812, AWAYTENS_PIN, GRB>(awaytens, NUM_LEDS);
   FastLED.addLeds<WS2812, BALLS_PIN, GRB>(balls, NUM_LEDS);
   FastLED.addLeds<WS2812, STRIKES_PIN, GRB>(strikes, NUM_LEDS);
   FastLED.addLeds<WS2812, OUTS_PIN, GRB>(outs, NUM_LEDS);
  FastLED.setMaxPowerInVoltsAndMilliamps(5, 500);
  FastLED.clear();
  FastLED.show();
  Serial.begin(9600);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
    pinMode(AWAYBUTTON_PIN, INPUT_PULLUP);
    pinMode(BALLSBUTTON_PIN, INPUT_PULLUP);
    pinMode(STRIKESBUTTON_PIN, INPUT_PULLUP);
    pinMode(OUTSBUTTON_PIN, INPUT_PULLUP);
 
}

void loop() {
   if (count>9) 
            tencount == tencount++;
            if (count>9) 
      count=0;
      if (tencount>9)
      tencount=0;

   if (strikescount>2)   
   strikescount = 0;
   if (ballscount>3)
   ballscount = 0;
   if (outscount>2)
   outscount=0;
      
    currentState = digitalRead(BUTTON_PIN);
   if(lastState == LOW && currentState == HIGH)
   count == count ++;

   awaycurrentState = digitalRead(AWAYBUTTON_PIN);
   if(awaylastState == LOW && awaycurrentState == HIGH)
   awaycount == awaycount ++;

   ballscurrentState = digitalRead(BALLS_PIN);
   if(ballslastState == LOW && ballscurrentState == HIGH)
   ballscount == ballscount ++;


strikescurrentState = digitalRead(STRIKESBUTTON_PIN);
   if(strikeslastState == LOW && strikescurrentState == HIGH)
   strikescount == strikescount ++;


outscurrentState = digitalRead(OUTSBUTTON_PIN);
   if(outslastState == LOW && outscurrentState == HIGH)
   outscount == outscount ++;

if (outscount==1) {
    outone(); }
    if (outscount==2) {
    outtwo(); }
    if (outscount==0) {
    outzero(); }

if (strikescount==1) {
    strikeone(); }
    if (strikescount==2) {
    striketwo(); }
    if (strikescount==0) {
    strikezero(); }

    if (ballscount==1) {
    ballone(); }
    if (ballscount==2) {
    balltwo(); }
    if (ballscount==3) {
    ballthree(); }
    if (ballscount==0) {
    ballzero(); }
 
   // Serial.println("The state changed from LOW to HIGH and the count is now...  ");
    //Serial.println(count);
    //Serial.println(tencount);
    String p1=";";
Serial.println(count + p1 + tencount);

  if (count==1) {
    one(); }
    if (count==2) {
    two();
     }
      if (count==0) {
    zero(); }
    if (count==3) {
    three();
     }
      if (count==4) {
    four(); }
    if (count==5) {
    five();
     }
      if (count==6) {
    six(); }
    if (count==7) {
    seven();
     }
      if (count==8) {
    eight(); }
    if (count==9) {
    nine();
     }

    if (tencount==1) {
    onehomesss(); }
    if (tencount==2) {
    twohomesss();
     }
      if (tencount==0) {
    zerohomesss(); }
    if (tencount==3) {
    threehomesss();
     }
      if (tencount==4) {
    fourhomesss(); }
    if (tencount==5) {
    fivehomesss();
     }
      if (tencount==6) {
    sixhomesss(); }
    if (tencount==7) {
    sevenhomesss();
     }
      if (tencount==8) {
    eighthomesss(); }
    if (tencount==9) {
    ninehomesss();
     }

     if (awaycount>9) 
            awaytencount == awaytencount++;
            if (awaycount>9) 
      awaycount=0;
      if (awaytencount>9)
      awaytencount=0;
      
 
 
   

  if (awaycount==1) {
    oneawayones(); }
    if (awaycount==2) {
    twoawayones();
     }
      if (awaycount==0) {
    zeroawayones(); }
    if (awaycount==3) {
    threeawayones();
     }
      if (awaycount==4) {
    fourawayones (); }
    if (awaycount==5) {
    fiveawayones ();
     }
      if (awaycount==6) {
    sixawayones (); }
    if (awaycount==7) {
    sevenawayones();
     }
      if (awaycount==8) {
    eightawayones (); }
    if (awaycount==9) {
    nineawayones ();
     }

    if (awaytencount==1) {
    oneawaytens(); }
    if (awaytencount==2) {
    twoawaytens();
     }
      if (awaytencount==0) {
    zeroawaytens(); }
    if (awaytencount==3) {
    threeawaytens();
     }
      if (awaytencount==4) {
    fourawaytens(); }
    if (awaytencount==5) {
    fiveawaytens();
     }
      if (awaytencount==6) {
    sixawaytens(); }
    if (awaytencount==7) {
    sevenawaytens();
     }
      if (awaytencount==8) {
    eightawaytens(); }
    if (awaytencount==9) {
    nineawaytens();
     }

    
//one ();
//delay (Delay);

 lastState = currentState;
 awaylastState = awaycurrentState;
 ballslastState = ballscurrentState;
 strikeslastState = strikescurrentState;
 outslastState = outscurrentState;
 

}

void one () {

 

 FastLED.clear();  

 

leds[2] = CRGB::Blue;

 

leds[6] = CRGB::Blue;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }

 

 

 

 //Number 2

 

void two () {

 

   FastLED.clear();

 

leds[4] = CRGB::Blue;

 

leds[5] = CRGB::Blue;

 

leds[2] = CRGB::Blue;

 

leds[1] = CRGB::Blue;

 

leds[3] = CRGB::Blue;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }    

 

 

 

 

 

 //Number 3

 

void three () {

 

  FastLED.clear();

 

leds[5] = CRGB::Blue;

 

leds[3] = CRGB::Blue;

 

leds[6] = CRGB::Blue;

 

leds[2] = CRGB::Blue;

 

leds[1] = CRGB::Blue;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }            

 

 

 

  //Number 4

 

void four () {

 

  FastLED.clear();

 

leds[2] = CRGB::Blue;

 

leds[3] = CRGB::Blue;

 

leds[0] = CRGB::Blue;

 

leds[6] = CRGB::Blue;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }   

 

 

 

  //Number 5

 

void five () {

 

  FastLED.clear();

 

leds[1] = CRGB::Blue;

 

leds[0] = CRGB::Blue;

 

leds[3] = CRGB::Blue;

 

leds[6] = CRGB::Blue;

 

leds[5] = CRGB::Blue;

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }  

 

            

 

//Number 6

 

void six () {

 

  FastLED.clear();

 

leds[0] = CRGB::Blue;

 

 

 

leds[3] = CRGB::Blue;

 

leds[6] = CRGB::Blue;

 

leds[4] = CRGB::Blue;

 

leds[5] = CRGB::Blue;

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }    

 

                   

 

//Number 7

 

void seven () {

 

  FastLED.clear();

 

 

 

leds[2] = CRGB::Blue;

 

leds[1] = CRGB::Blue;

 

leds[6]= CRGB::Blue;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }             

 

 

 

 

 

//Number 8

 

void eight () {

 

  FastLED.clear();

 

leds[1] = CRGB::Blue;

 

leds[0] = CRGB::Blue;

 

leds[2] = CRGB::Blue;

 

leds[3] = CRGB::Blue;

 

leds[4] = CRGB::Blue;

 

leds[5] = CRGB::Blue;

 

leds[6] = CRGB::Blue;

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }             

 

 //Number 9

 

void nine () {

 

  FastLED.clear();

 

leds[1] = CRGB::Blue;

 

leds[0] = CRGB::Blue;

 

leds[2] = CRGB::Blue;

 

leds[3] = CRGB::Blue;

 

leds[6] = CRGB::Blue;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }   

 

                    

 

 //Number 0

 

void zero () {

 

  FastLED.clear();

 

leds[1] = CRGB::Blue;

 

leds[0] = CRGB::Blue;

 

leds[2] = CRGB::Blue;

 

leds[4] = CRGB::Blue;

 

leds[5] = CRGB::Blue;

 

leds[6] = CRGB::Blue;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

}

 


void onehomesss () {

 

 FastLED.clear();  

 

homesss[2] = CRGB::Blue;

 

homesss[6] = CRGB::Blue;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }

 

 

 

 //Number 2

 

void twohomesss () {

 

   FastLED.clear();

 

homesss[4] = CRGB::Blue;

 

homesss[5] = CRGB::Blue;

 

homesss[2] = CRGB::Blue;

 

homesss[1] = CRGB::Blue;

 

homesss[3] = CRGB::Blue;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }    

 

 

 

 

 

 //Number 3

 

void threehomesss () {

 

  FastLED.clear();

 

homesss[5] = CRGB::Blue;

 

homesss[3] = CRGB::Blue;

 

homesss[6] = CRGB::Blue;

 

homesss[2] = CRGB::Blue;

 

homesss[1] = CRGB::Blue;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }            

 

 

 

  //Number 4

 

void fourhomesss () {

 

  FastLED.clear();

 

homesss[2] = CRGB::Blue;

 

homesss[3] = CRGB::Blue;

 

homesss[0] = CRGB::Blue;

 

homesss[6] = CRGB::Blue;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }   

 

 

 

  //Number 5

 

void fivehomesss () {

 

  FastLED.clear();

 

homesss[1] = CRGB::Blue;

 

homesss[0] = CRGB::Blue;

 

homesss[3] = CRGB::Blue;

 

homesss[6] = CRGB::Blue;

 

homesss[5] = CRGB::Blue;

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }  

 

            

 

//Number 6

 

void sixhomesss () {

 

  FastLED.clear();

 

homesss[0] = CRGB::Blue;

 

 

 

homesss[3] = CRGB::Blue;

 

homesss[6] = CRGB::Blue;

 

homesss[4] = CRGB::Blue;

 

homesss[5] = CRGB::Blue;

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }    

 

                   

 

//Number 7

 

void sevenhomesss () {

 

  FastLED.clear();

 

 

 

homesss[2] = CRGB::Blue;

 

homesss[1] = CRGB::Blue;

 

homesss[6]= CRGB::Blue;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }             

 

 

 

 

 

//Number 8

 

void eighthomesss () {

 

  FastLED.clear();

 

homesss[1] = CRGB::Blue;

 

homesss[0] = CRGB::Blue;

 

homesss[2] = CRGB::Blue;

 

homesss[3] = CRGB::Blue;

 

homesss[4] = CRGB::Blue;

 

homesss[5] = CRGB::Blue;

 

homesss[6] = CRGB::Blue;

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }             

 

 //Number 9

 

void ninehomesss () {

 

  FastLED.clear();

 

homesss[1] = CRGB::Blue;

 

homesss[0] = CRGB::Blue;

 

homesss[2] = CRGB::Blue;

 

homesss[3] = CRGB::Blue;

 

homesss[6] = CRGB::Blue;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }   

 

                    

 

 //Number 0

 

void zerohomesss () {

 

  FastLED.clear();

 

homesss[1] = CRGB::Blue;

 

homesss[0] = CRGB::Blue;

 

homesss[2] = CRGB::Blue;

 

homesss[4] = CRGB::Blue;

 

homesss[5] = CRGB::Blue;

 

homesss[6] = CRGB::Blue;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 
}


void oneawaytens () {

 

 FastLED.clear();  

 

awaytens[2] = CRGB::Red;

 

awaytens[6] = CRGB::Red;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }

 

 

 

 //Number 2

 

void twoawaytens () {

 

   FastLED.clear();

 

awaytens[4] = CRGB::Red;

 

awaytens[5] = CRGB::Red;

 

awaytens[2] = CRGB::Red;

 

awaytens[1] = CRGB::Red;

 

awaytens[3] = CRGB::Red;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }    

 

 

 

 

 

 //Number 3

 

void threeawaytens () {

 

  FastLED.clear();

 

awaytens[5] = CRGB::Red;

 

awaytens[3] = CRGB::Red;

 

awaytens[6] = CRGB::Red;

 

awaytens[2] = CRGB::Red;

 

awaytens[1] = CRGB::Red;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }            

 

 

 

  //Number 4

 

void fourawaytens () {

 

  FastLED.clear();

 

awaytens[2] = CRGB::Red;

 

awaytens[3] = CRGB::Red;

 

awaytens[0] = CRGB::Red;

 

awaytens[6] = CRGB::Red;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }   

 

 

 

  //Number 5

 

void fiveawaytens () {

 

  FastLED.clear();

 

awaytens[1] = CRGB::Red;

 

awaytens[0] = CRGB::Red;

 

awaytens[3] = CRGB::Red;

 

awaytens[6] = CRGB::Red;

 

awaytens[5] = CRGB::Red;

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }  

 

            

 

//Number 6

 

void sixawaytens () {

 

  FastLED.clear();

 

awaytens[0] = CRGB::Red;

 

 

 

awaytens[3] = CRGB::Red;

 

awaytens[6] = CRGB::Red;

 

awaytens[4] = CRGB::Red;

 

awaytens[5] = CRGB::Red;

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }    

 

                   

 

//Number 7

 

void sevenawaytens () {

 

  FastLED.clear();

 

 

 

awaytens[2] = CRGB::Red;

 

awaytens[1] = CRGB::Red;

 

awaytens[6]= CRGB::Red;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }             

 

 

 

 

 

//Number 8

 

void eightawaytens () {

 

  FastLED.clear();

 

awaytens[1] = CRGB::Red;

 

awaytens[0] = CRGB::Red;

 

awaytens[2] = CRGB::Red;

 

awaytens[3] = CRGB::Red;

 

awaytens[4] = CRGB::Red;

 

awaytens[5] = CRGB::Red;

 

awaytens[6] = CRGB::Red;

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }             

 

 //Number 9

 

void nineawaytens () {

 

  FastLED.clear();

 

awaytens[1] = CRGB::Red;

 

awaytens[0] = CRGB::Red;

 

awaytens[2] = CRGB::Red;

 

awaytens[3] = CRGB::Red;

 

awaytens[6] = CRGB::Red;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }   

 

                    

 

 //Number 0

 

void zeroawaytens () {

 

  FastLED.clear();

 

awaytens[1] = CRGB::Red;

 

awaytens[0] = CRGB::Red;

 

awaytens[2] = CRGB::Red;

 

awaytens[4] = CRGB::Red;

 

awaytens[5] = CRGB::Red;

 

awaytens[6] = CRGB::Red;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

}

void oneawayones () {

 

 FastLED.clear();  

 

awayones[2] = CRGB::Red;

 

awayones[6] = CRGB::Red;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }

 

 

 

 //Number 2

 

void twoawayones () {

 

   FastLED.clear();

 

awayones[4] = CRGB::Red;

 

awayones[5] = CRGB::Red;

 

awayones[2] = CRGB::Red;

 

awayones[1] = CRGB::Red;

 

awayones[3] = CRGB::Red;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }    

 

 

 

 

 

 //Number 3

 

void threeawayones () {

 

  FastLED.clear();

 

awayones[5] = CRGB::Red;

 

awayones[3] = CRGB::Red;

 

awayones[6] = CRGB::Red;

 

awayones[2] = CRGB::Red;

 

awayones[1] = CRGB::Red;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }            

 

 

 

  //Number 4

 

void fourawayones () {

 

  FastLED.clear();

 

awayones[2] = CRGB::Red;

 

awayones[3] = CRGB::Red;

 

awayones[0] = CRGB::Red;

 

awayones[6] = CRGB::Red;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }   

 

 

 

  //Number 5

 

void fiveawayones () {

 

  FastLED.clear();

 

awayones[1] = CRGB::Red;

 

awayones[0] = CRGB::Red;

 

awayones[3] = CRGB::Red;

 

awayones[6] = CRGB::Red;

 

awayones[5] = CRGB::Red;

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }  

 

            

 

//Number 6

 

void sixawayones () {

 

  FastLED.clear();

 

awayones[0] = CRGB::Red;

 

 

 

awayones[3] = CRGB::Red;

 

awayones[6] = CRGB::Red;

 

awayones[4] = CRGB::Red;

 

awayones[5] = CRGB::Red;

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }    

 

                   

 

//Number 7

 

void sevenawayones () {

 

  FastLED.clear();

 

 

 

awayones[2] = CRGB::Red;

 

awayones[1] = CRGB::Red;

 

awayones[6]= CRGB::Red;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }             

 

 

 

 

 

//Number 8

 

void eightawayones () {

 

  FastLED.clear();

 

awayones[1] = CRGB::Red;

 

awayones[0] = CRGB::Red;

 

awayones[2] = CRGB::Red;

 

awayones[3] = CRGB::Red;

 

awayones[4] = CRGB::Red;

 

awayones[5] = CRGB::Red;

 

awayones[6] = CRGB::Red;

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }             

 

 //Number 9

 

void nineawayones () {

 

  FastLED.clear();

 

awayones[1] = CRGB::Red;

 

awayones[0] = CRGB::Red;

 

awayones[2] = CRGB::Red;

 

awayones[3] = CRGB::Red;

 

awayones[6] = CRGB::Red;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();

 

          }   

 

                    

 

 //Number 0

 

void zeroawayones () {

 

  FastLED.clear();

 

awayones[1] = CRGB::Red;

 

awayones[0] = CRGB::Red;

 

awayones[2] = CRGB::Red;

 

awayones[4] = CRGB::Red;

 

awayones[5] = CRGB::Red;

 

awayones[6] = CRGB::Red;

 

 

 

    FastLED.setBrightness(255);

 

    FastLED.show();


}

void ballone () {

  FastLED.clear();  
balls[0] = CRGB::Color1;
FastLED.setBrightness(255);
FastLED.show();
}

void balltwo () {

  FastLED.clear();  
balls[0] = CRGB::Color1;
balls[1] = CRGB::Color1;
FastLED.setBrightness(255);
FastLED.show();
}

void ballthree () {

  FastLED.clear();  
balls[0] = CRGB::Color1;
balls[1] = CRGB::Color1;
balls[2] = CRGB::Color1;
FastLED.setBrightness(255);
FastLED.show();
}

void ballzero () {

  FastLED.clear();  
balls[0] = CRGB::Black;
balls[1] = CRGB::Black;
balls[2] = CRGB::Black;
FastLED.setBrightness(255);
FastLED.show();
}


void strikeone () {

  FastLED.clear();  
strikes[0] = CRGB::Color1;
FastLED.setBrightness(255);
FastLED.show();
}

void striketwo () {

  FastLED.clear();  
strikes[0] = CRGB::Color1;
strikes[1] = CRGB::Color1;
FastLED.setBrightness(255);
FastLED.show();
}

void strikezero () {

  FastLED.clear();  
strikes[0] = CRGB::Black;
strikes[1] = CRGB::Black;
FastLED.setBrightness(255);
FastLED.show();
}

void outone () {

  FastLED.clear();  
outs[0] = CRGB::Color1;
FastLED.setBrightness(255);
FastLED.show();
}

void outtwo () {

  FastLED.clear();  
outs[0] = CRGB::Color1;
outs[1] = CRGB::Color1;
FastLED.setBrightness(255);
FastLED.show();
}

void outzero () {

  FastLED.clear();  
outs[0] = CRGB::Black;
outs[1] = CRGB::Black;
FastLED.setBrightness(255);
FastLED.show();
}

This comparison makes no sense. Normally you would be doing an assignment (=) but that leads to UNDEFINED BEHVIOR because you would be using an increment AND an assignment to the same variable.

To add 1 to a variable, use one of these:
variable++;
++variable;
variable += 1;
variable = variable + 1;

DO NOT use variable = variable++; because that doesn't always work.

1 Like

Changing that didn't help. Lights still flashing.

wow, a lot of code. at the very least time consuming to read, write and debug. i'm sure there's a more methodical way of handling all the combinatorics

when should the come on -- at startup or only after a button press?
do they stop "flashing"

since you configured the button pins as INPUT_PULLUP, i assume you connect the button between the pin and ground so that the pin is normally HIGH and pressing the button pulls is LOW.

but the logic in the code above suggests that you expect button pin to be HIGH when the button is pressed. i think the result may be that the action occurs when the button is released

but the other thing is there is no debounce, resulting in multiple events.

I'm using momentary buttons, so when the button is pressed, the light comes on or changes. Whenever a light is "on" it is flashing. A better term to use would actually be flickering. So whether a light is on at startup or is turn on as a result of the button press, they are always flickering. And yes, the button is wired between the pin and the ground to so there is no bounce. The code all "works" fine, it's just the flickering of the leds that is the problem.

if you don't want the leds to flicker how can you say the code works fine. there must be a problem.

can you do something that prevents the code in loop from running to show that the flickering is not do to the code running? can you trap the code in a while (1) ; when the count reaches some point

Sorry by "works" I meant that it's doing all the other actions properly, but for the flickering. I need some clarity by what you mean by...

I fixed it by taking out the Serial reference in the code.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.