user31208: I'm trying to use momentary push buttons to switch bi color LED between RED and GREEN. I've got one working, but when I try to adapt the code for more buttons, it doesn't work. I'm just changing the buttonnumbers (which are defined).
It compiles and uploads without error.  
void loop() {
  byte currentButton1Status = digitalRead(button1);
  if (currentButton1Status == button1Status)
    lastEqualButtonTime = millis();
  else if ((millis() - lastEqualButtonTime) > debounceTimeMs)
  {
    lastEqualButtonTime = millis();
    button1Status = currentButton1Status;

    if (button1Status == LOW) {
      digitalWrite(17, !digitalRead(17));
      digitalWrite(16, !digitalRead(16));
    }
  }

  byte currentButton2Status = digitalRead(button2);
  if (currentButton2Status == button2Status)
    lastEqualButtonTime = millis();
  else if ((millis() - lastEqualButtonTime) > debounceTimeMs)
  {
    lastEqualButtonTime = millis();
    button2Status = currentButton2Status;

    if (button2Status == LOW) {
      digitalWrite(15, !digitalRead(15));
      digitalWrite(14, !digitalRead(14));
    }
  }    
}


user313: You've only said "... it doesn't work" which doesn't give much to go on, but the first thing I see that might contribute it not working as (I think) you expect it o, is only one lastEqualButtonTime variable for both buttons (is it a global? I don't see a definition). I think you'll need one for each.

31208: <p>I'm trying to use momentary push buttons to switch bi color LED between RED and GREEN. I've got one working, but when I try to adapt the code for more buttons, it doesn't work. I'm just changing the buttonnumbers (which are defined).<br>
It compiles and uploads without error.  </p>

<pre><code>void loop() {
  byte currentButton1Status = digitalRead(button1);
  if (currentButton1Status == button1Status)
    lastEqualButtonTime = millis();
  else if ((millis() - lastEqualButtonTime) &gt; debounceTimeMs)
  {
    lastEqualButtonTime = millis();
    button1Status = currentButton1Status;

    if (button1Status == LOW) {
      digitalWrite(17, !digitalRead(17));
      digitalWrite(16, !digitalRead(16));
    }
  }

  byte currentButton2Status = digitalRead(button2);
  if (currentButton2Status == button2Status)
    lastEqualButtonTime = millis();
  else if ((millis() - lastEqualButtonTime) &gt; debounceTimeMs)
  {
    lastEqualButtonTime = millis();
    button2Status = currentButton2Status;

    if (button2Status == LOW) {
      digitalWrite(15, !digitalRead(15));
      digitalWrite(14, !digitalRead(14));
    }
  }    
}
</code></pre>
 313: <p>You've only said "... it doesn't work" which doesn't give much to go on, but the first thing I see that might contribute it not working as (I think) you expect it o, is only one <code>lastEqualButtonTime</code> variable for both buttons (is it a global? I don't see a definition). I think you'll need one for each.</p>
