Hi everyone,
My first time posting so please bear with me. I was tasked with a project for my church, I just want to make sure I got this right before I start ordering parts and piecing everything together.
**Background: Every few months several churches (5 or more) gather together, one of the main events is the Battle of the Kids… basically. The children are grouped into several age groups and pit against one another in a bible trivia challenge. The only way we have as of now to determine who is chosen to answer a question is by who raises their hand first. This is not very precise. A lot of guessing when you have 15 six year olds all raising their hands.
**Project: Jeopardy style buzz in with hand held buttons+LED’s. Person reading the questions(PRTQ) will enable the kids buttons when he presses his button.
1: PRTQ reads a question…
2: PRTQ presses his master button – LED illuminates on “junction box” all the buttons are connected to (TRRS audio cable).
3: Kids can press their buttons.
4: Kid that presses first will have their built in LED light up. All other kids are locked out.
5: Loop times out and waits for another press from PRTQ.
/* jeopardy style game-- master button (masClick) will enable 20+ other buttons (chiClick) to "buzz" in.
Once a player button is pressed, the others are locked out and the player's corresponding LED is lit indicating which player
buzzed in first.
The loop resets after 5 seconds and waits for the master to be pressed again.*/
const int masClick = 53;// iteration should commence once masClick pin 53 goes HIGH
const int masClickLED = 52; // will illuminate when master button is pressed
const int chiClick[] = {2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,18,19,20,21,22,23};
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
const int chiClickLED[] = {24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45};
const int pinCount = 22;
unsigned long debounceTime = 0;
unsigned long debounceDelay = 55;
int masClickState ;
int preMasClickState = LOW ;
int masLedState = LOW ;
int chiState ;
int preChiState = LOW ;
int chiLedState = LOW ;
void setup() {
pinMode (masClick, INPUT);
pinMode (masClickLED, OUTPUT);
pinMode (chiClick, INPUT);
pinMode (chiClickLED, OUTPUT);
digitalWrite (masClickLED, LOW);
digitalWrite (chiClickLED, LOW);
}
void loop() {
int reading = digitalRead(masClick);
if(reading != preMasClickState){ // debouncing masClick button
debounceTime = millis();
}
if ((millis() - debounceTime) > debounceDelay) {
masClickState = reading;
}
if ( masClickState == masClick) {
digitalWrite (masClickLED, HIGH);
int i=0;
for (i=0; i<pinCount; i++){
int chiReading = digitalRead(chiClick[i]); // start debouncing chiClick here?
if(chiReading != preChiState){
debounceTime = millis();
}
if ((millis() - debounceTime) > debounceDelay) {
chiState = chiReading;
}
if (chiState == chiClick[i]){
digitalWrite (chiClickLED[i], HIGH) ;
delay (5000);
break ;
}
}
}
}
ChurchJeopardy.ino (2.08 KB)