Go Down

Topic: Jeopardy lockout LED indicator  (Read 734 times) previous topic - next topic


I'm trying to make a Jeopardy buzzer system. It's a pretty basic idea:

Players 1-3 attempt to press their own button
Whoever presses first, only their LED lights up
A buzzer also plays a tone
Moderator presses reset button
... Players can press their buttons again

How do I lock out the other players from chiming in and activating the LED's & buzzer after someone has already chimed in?

The code below only shows one player- but that one player could keep pressing their button and set off the buzzer tone (which gets annoying). I would greatly appreciate some help- I'm learning, but on a time crunch.

Code: [Select]
int button1 = 3; //spst button
int led1 = 11;
int buzzer = 5;
int reset = 7; //reset spst button

boolean pressed = false;
boolean notpressed = true;
boolean bright = true;
boolean dark = false;

void setup()
  pinMode(led1, OUTPUT);
    pinMode(buzzer, OUTPUT);
  pinMode(button1, INPUT);
  digitalWrite(button1, HIGH);
    pinMode(reset, INPUT);
    digitalWrite(reset, HIGH);
void loop() {
  if (digitalRead(button1) == pressed)
digitalWrite(led1, bright); //turn on led
digitalWrite(buzzer, bright); //turn on buzzer
digitalWrite(buzzer, !bright); //turn off buzzer
else if (digitalRead(reset) == pressed)
  digitalWrite(led1, dark); //turn off led when reset pressed


Seems like you already answered your question:

>Players 1-3 attempt to press their own button
>Whoever presses first, only their LED lights up
>A buzzer also plays a tone
>Moderator presses reset button
>... Players can press their buttons again

wait for any button press();
light an appropriate LED and sound a buzzer();
wait for the moderator button();

That is, stop reading player buttons once one of them is pressed.
Then, of course, will come debouncing. And if your players are lightning fast - you may want to read the data from the port directly, but I guess that's not what you're about here.


I am just getting into this language for programming, but I have been programming for a few years in other languages.  Here is what I would try:

      if any button pressed and Trebek is ready then
      end if

// code to figure out which guy pressed his button, make his LED and Buzzer activate
//do a short countdown.

Trebek has his own switch that disables the buzzers. As long as the the buzzer() module is running, no one else can press a button.  This way you dont actually have to individually lock out the other two.  They just wont be read until the countdown is over and Trebek is ready.  You can make it to where as long as Trebek is holding down his button, and no countdown is running, it will be waiting for someone to buzz in.  When Trebek lifts his button, someone answered correctly or its time to move on to another question.

Go Up