quiz game controller - not all LED's lighting

Hello all!

I’m fairly new to Arduino and having a lot of fun with it so far. My programming experience is pretty minimal, but the tutorials here and other places have been a treasure trove of good info.

I decided to make a quiz game controller for my classroom. There are many great examples out there, but wanted to make one from scratch as a learning exercise. Currently I have it set up for three teams. When a team’s button is pressed, their LED will flash several times, locking out the other team buttons. I’m planning on adding a buzzer also with different tones for different teams.

The problem that I’m running into is that only two of the buttons will work. The third button never initiates the flashing. All LEDs and buttons will work independently, so its most likely not a hardware issue. That leaves my poor attempt at coding. Any help/feedback is much appreciated! (Please excuse the many comments, those help me keep track of what is going on)

/*
 * LED Quiz Game Control
 * definitely a work in progress
 */

const int rdPin = 9;  //assign LED pins
const int grPin = 10;
const int blPin = 11;
const int rdBtn = 2;  //assign button pins
const int grBtn = 3;
const int blBtn = 4;
const int flashes = 5;  //times to flash LED

void setup() {
pinMode(rdPin, OUTPUT); //LED pins to output
pinMode(grPin, OUTPUT);
pinMode(blPin, OUTPUT);
pinMode(rdPin, INPUT);  //button pins to input
pinMode(grBtn, INPUT);
pinMode(blBtn, INPUT);
digitalWrite(grBtn, HIGH);  //enalbe internal pullup resistors
digitalWrite(rdBtn, HIGH);
digitalWrite(blBtn, HIGH);
}

void loop() {
int grVal = digitalRead(grBtn); //read buttons
int rdVal = digitalRead(rdBtn);
int blVal = digitalRead(blBtn);
  if ((rdVal == LOW) && (grVal == HIGH) && (blVal == HIGH)) { //on red press send red pin to answer function
    answerLed(rdPin);
  }
  if ((rdVal == HIGH) && (grVal == LOW) && (blVal == HIGH)){  //on green press send green pin to answer function
    answerLed(grPin);
  }
  if ((rdVal == HIGH) && (grVal == HIGH) && (blVal == LOW)){  //on blue press send blue pin to answer function
    answerLed(blPin);
  }
}

void answerLed (int answerPin){ //flash the color that answered 5x slow then 10x fast
  for (int i = 0; i < flashes; i++){
  digitalWrite(answerPin, HIGH);
  delay(500);
  digitalWrite(answerPin, LOW);
  delay(500);
  }
  for (int i = 0; i < (2*flashes); i++){
    digitalWrite(answerPin, HIGH);
    delay(250);
    digitalWrite(answerPin, LOW);
    delay(250);
  }
}

Many thanks!

Look in your pinMode calls. Is rdPin an INPUT or an OUTPUT?

That one I caught :) It was a copy/paste error, and corrected. Still the same issue though. Red works, green works, blue does not.

Code looks fine. Check your wiring. Post schematic.

Well, it was a wiring problem. But I have no idea exactly what it was. I removed/reattached every lead, and no joy. Then I did a very frustrated complete rebuild. Now it works. I’ll post the schematic anyway.

Thank you for the help! Please excuse me while I go have some words with Mr. Faraday.