0

I'm currently trying to write a code for an Arduino Uno. I have four (4) rows of six (6) LED lights, and I am trying to get them to run by themselves on a counter. Below is my coding, but I have run into an issue where the lights turn on but will not turn off. I am currently using TinkerCad to try and troubleshoot. Although the code addresses all four (4) rows of lights, I have only coded for one in the void loop(). Any advice is helpful!

 // Test for board

int LEDblue = 13;
int LEDblueON = 1000;
int LEDblueOFF = 1000;

int LEDgreen = 12;
int LEDgreenON = 2000;
int LEDgreenOFF = 2000;

int LEDyellow = 11;
int LEDyellowON = 4000;
int LEDyellowOFF = 4000;

int LEDred = 10;
int LEDredON = 8000;
int LEDredOFF = 8000;

int CounterBlue = 0;
int CounterGreen = 0;
int CounterYellow = 0;
int CounterRed = 0;

void setup()
{
  pinMode (LEDblue, OUTPUT);
  pinMode (LEDgreen, OUTPUT);
  pinMode (LEDyellow, OUTPUT);
  pinMode (LEDred, OUTPUT);
}

void loop()
{
  if (CounterBlue <LEDblueON);
  {
    digitalWrite(LEDblue, HIGH);
  }
  if (CounterBlue=LEDblueON+LEDblueOFF);
  {
    digitalWrite(LEDblue, LOW);
  }
  if(CounterBlue>LEDblueON+LEDblueOFF);
  {
    (CounterBlue= 0);
  }
  delay(1);
}
gre_gor
  • 6,669
  • 9
  • 47
  • 52
  • 2
    You never change `CounterBlue`. And `;` after the if condition doesn't look right. Also `CounterBlue=LEDblueON+LEDblueOFF` is not a comparison. – gre_gor Jul 18 '17 at 17:44
  • I changed the "CounterBlue=..." to "CounterBlue – Ajohnson Jul 18 '17 at 17:51
  • The name of the variable is `Counter*` and you aren't counting it. If you write code that acts differently depending on different values of a variable, it's expected that the variable changes at some point. – gre_gor Jul 19 '17 at 00:25
  • All of your `if` statements have `;` that should not be there.... And where do you increment your counter? – Michaël Roy Jul 21 '17 at 15:56

1 Answers1

0

The Main Problem is the fact that after your if statements' conditions e.g.

if (CounterBlue <LEDblueON);
  {
    digitalWrite(LEDblue, HIGH);
  }

There is a ; before the bracket. If you changed it to

if (CounterBlue <LEDblueON)
  {
    digitalWrite(LEDblue, HIGH);
  }

It should work fine.

Fauzan
  • 252
  • 4
  • 10
scsh
  • 26
  • 4