2 Player Quiz game - not sure where to start...

Hello. I am searching for help. I am the children's pastor at my church, so my knowledge of programing is less than basic. I want to build a 2 player game show. When one button is pushed, it would lock out the other button, plus I would like it to light up 8-10 LED lights in sequence then ring a doorbell striker, all on the side of the one who pushed the button first. I have a circus theme in our kids church, so I want to have the buttons in "Ring the Bell" towers on either side of the room.

My original thought is actually using three Arduno boards. One main to control the two players and the reset. The other two would take an input signal from the first board if their side is activated, causing it to do the LEDs, lighting them from bottom to top like the weight on a "ring the bell" game, and either a bell striker or using a sound shield and playing a bell gong sound. Whatever will be simpler and less expensive.

I currently have one Arduino Uno.

I do know how to do PCB boards (if someone creates the schematic since I have no clue what does what), so I can put a wire in a breadboard or attach a resister.... I just don't understand the language nor the math.

If anyone can help me with the coding and other ideas, PLEASE help.

Thank you. Have a very Blessed new year!!!

buzzlighthouse.jpg

Sounds like you want something like a jeopary game buzz in device?
You can do it with one Arduino. Use one input pin for one player's button, another input pin for another player, up to say 6 players, and you still have 6 pins for output devices.
Have you done any breadboarding and coding yet?
Start with a project that gives you a part of your project. Say an LED blinker that blinks 2 different LEDs. Turn one on and the other off alternating.

int pin7 = 7;
int pin 8 = 8;

void setup() {

pinMode(pin7, OUTPUT);
pinMode(pin8, OUTPUT);
}

void loop() {
digitalWrite(pin7, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pin8, LOW); // turn the other LED off
delay(1000); // wait for a second

digitalWrite(pin8, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pin7, LOW); // turn the other LED off
delay(1000); // wait for a second

}

Get this running with 2 LEDs ....

then learn to use subroutines, like so

void oneOneOneOff(int pinToTurnOn , int pinToTurnOff) {
digitalWrite(pinToTurnOn , HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinToTurnOff, LOW); // turn the other LED off

}

Now you're ready to put some parts together
in your main loop, something like:

while (buttonNotPressed)
playerThatPushedButton = captureButtonPress();

lightLED_for(playerThatPushedButton);

function "captureButtonPress" would return an integer, representing the pin where you detected
the button press

etc. etc.

pseudo code

while (player hasn't pushed a button)
wait for button press

If I may it's a bit more complicated that this for captureButtonPress. To be fair to all players, the function should not use a digitalRead in sequence on all the input pins as it would give the player on the first pin a few microseconds advantage or disadvantage against its friends. Pins need to all be on the same PORT and press detection should be done reading the whole port in one go. This way you are fair to all players, you sample the status of their button exactly at the same time.

@kidpreacher5325, do not cross-post.

@kidpreacher5325, do not hijack.

kidpreacher5325:
My original thought is actually using three Arduno boards. One main to control the two players and the reset. The other two would take an input signal from the first board if their side is activated

So from what you wrote I understand that you want to have three Arduino devices:

one main Arcade device connected to two Quiz-Buzzers in the middle of room

two light/sound action devices at the sides of the room

How big is the room? Distance from the main Arcade device to the light/sound devices in meters or feet?

You will have to send information about pressed buttons from the main Arcade device to the light/sound devices. Is it possible to se cables/wires for that?
Or are you bound to some "wireless" solution?

How do you want to power all the devices?
Is it possible to use an USB 5V power adapter for each Arduino device?

Did you already find a pair of suitable "action buttons" or "quiz buzzers" for your main device?

Programming should be easy, as as long as you can do everything cabled/wired".

But maybe become complicated when you need a wireless solution.

Jurs... To reply to your answer...

The room I am in is 54 foot wide. I can run the wires under the stage, and where I plan to put each player as well as the control board all have a wall outlet nearby, so each board would have its own power supply.

Photo of room included. The lower set of stages are movable, so wires and power will be easy to run. Don't need wireless, thankfully.

I will use three arduino boards if necessary, since I want to have sound at each players position. If the main arduino board could activate sound on each side along with the lights I would just use the single, but that actually seemed more complicated than having one board on each side to do the light tree and the sound. Let me break this down more...

For the push buttons, I have built heavy duty pads with a piece of metal on each side, so when they are hit, they make contact completing the circuit.. Springs seperate the plates when not activated. Since I work with kids, this system is almost unbreakable no matter how hard they pound on it... This will send a signal to the Quiz show program arduino and lock out a signal from the other side. I could then put in a timed reset to give the light tree time to do its display and ring. So I need the coding for this.

Then the output from the game board would travel to a second arduino on the side where the button was pushed. That would run the light tree and sound, and then reset. I already have the coding for this from a light countdown tower I built last year. I just have to shorten the delays.

So the signal trail would be Push button to Arduino A, A to either B or C, then reset.

Thank you so much for your help.

J-M-L - I am not sure what you mean by Digital Read, but I appreciate the idea of not giving one side an advantage over the other because the code reads one pin before the other. But I do not understand how I would code that (as if I understand any of this...).

To Coding Badly - I do not mean to be hijacking or cross posting, I appologize if I am incorrect in what I am doing. I am a minister, not a programer nor electricial engineer. Please forgive me.

Steve - I have done NOTHING on this project yet except ask questions, and built the push button paddles. I have my current arduino Uno attached to a breadboard with a countdown light tree I did last year - My only other attempt at learing coding. Thanks for the guideance.

J-M-L - I am not sure what you mean by Digital Read, but I appreciate the idea of not giving one side an advantage over the other because the code reads one pin before the other. But I do not understand how I would code that (as if I understand any of this...).

in order to see if your buttons are pressed, you will like do something like

   buttonAState = digitalRead(buttonAPin);
   buttonBState = digitalRead(buttonBPin);

Meaning that if B has pressed after A but within the small delay it took to go read the state of buttonA, you will still count them tie. that's unfair because A should have won.

so you need to read both pins at then same time, which you can do using PORT registers

(I know it's only a few microseconds, but this is for the sake of fairness :slight_smile: )

code:
int inputPins[4] = {5,4,3,2}; // The numbers of the switch pins.
int outputPins[4] = {13,12,11,10}; // The numbers of the LED pins.

// Some variables to control processing
int maxPins = 4; // Max number of pin sets
unsigned long WinDelayTime = 5000; // Number of milliseconds to light LEDs

void winner(int); // Function definition.

//
// Begin processing
//
void setup() {
/*
setup() is performed once when the Arduino is powered up or reset.
*/
// Initialize the LED pins.
// This tells the Arduino how the pins will be used.
for(int p=0; p < maxPins; p++) {
pinMode(inputPins[p], INPUT); // Make this an input pin.
pinMode(outputPins[p], OUTPUT); // Make this an output pin.
}
}

void loop(){
/*
The loop() function is executed after the setup() function completes.
As the name implies the loop() function loops forever or until the Arduino is reset.
*/

int val = HIGH; // Used to determine if an input pin's state has changed.

for(int p=0; p < maxPins; p++) {
// Read the state of each input pin.
val = digitalRead(inputPins[p]); // Reads value of the input pin.

if (val == LOW){
// If a pin goes LOW then someone pressed a button.
winner(p); // Call the winner() function with winning pin set.
}
}
}

void winner(int p){
// Set the output pin HIGH to send power to the button's LED circuit.
digitalWrite(outputPins[p], HIGH); // Turn the LEDs on

// Wait WinDelayTime milliseconds
delay(WinDelayTime);

// Set the output pin LOW to kill power to the button's LED circuit.
digitalWrite(outputPins[p], LOW); // Turn the LEDs off
}

Found this sketch. led on digital 13, 12, 11, 10 all to digital gnd. Uploaded and now it just cycles all 4 LEDs. Not sure what to use for power to pins 5, 4, 3, and 2, plus waning to make it set to ready mode...

kidpreacher5325:
LEDs. Not sure what to use for power to pins 5, 4, 3, and 2, plus waning to make it set to ready mode...

When using buttons as input sensors, you need to use either pulll-up or puill-down resistors with them in the circuit.

Do you know the button circuits for pull-up or pull down resistors and how to create them?

Here is how to create a pull-down button circuit, this seems to be used in your sketch:

1.create a a series circuit rom didital input pin to a a 1K or 4K7 resistor and then to GND.
Also connect the same input pin(as used above) to one side of the push button switch
connect the other side of the push button switch to 5V.

That's a "push button circuit using a pull-down resistor.
If the button is not pressed, the input pin is "pulled down" to GND and input reads LOW.

When the button is pressed, it connects the input to 5V and the input reads HIGH.

That's how newbies like it best: released button reads LOW, pressed button reads HIGH.

Button circuit using a pull-up resistor instead of pull-down resistor is different.

But normally you'd better use circuit with a pull-up resistor.
In that case, a released button would read HIGH and a pressed button would read LOW.

Same thing with reversed HIGH/LOW logic.
And a big advantage: You actually do NOT need to have an external pull-up in your circuit.

Wiring can be much easier when activating the "internal pull-up resistor" on the ATMEGA by software!
That's simple:
Write "pinMode(pinNumber,INPUT_PULLUP); " in the setup() function and it is done!
input pin is pulled high, without actually wiring an external pull-up resistor in the circuit.
Works reliable in "normal environments" for disstances of 1-2 feet between Arduino and push button.

What's the distance of your "main Arduino" to the push buttons? More or less than 2 feet?

I tried to create an ASCII drawing of both circuits:

§button circuit with pull-down resistor" and "button circuit with pull-up resistor"
Here it is:

buttton circuit with pull-down resistor:
                   
                    _______
+------------------|_______|-----------------+--------------- o/o--------  +5V
|                    4K7                     |               Switch
|                                            |
|                                            |
|                                            |
|                                            |
|                                            |
|                                            |
|                                            |
|                                            |
GND                                         INPUT(Arduino)






buttton circuit with pull-up resistor:
                   
                    _______
+------------------|_______|-----------------+--------------- o/o-------  GND
|                    4K7                     |               Switch
|                                            |
|                                            |
|                                            |
|                                            |
|                                            |
|                                            |
|                                            |
|                                            |
+5V                                         INPUT(Arduino)

It will be about 16 feet from the quiz circuit to each player control. I understand pull down from my pcb boards - just do not know the coding. Plus I am a little worried about putting power to the wrong input and blowing the board... For instance, is there a difference between the ground pins on the digital side and the other side on the UNO? Can I run the streight 5v into an input to trigger the game, or do I need to put a resister on it?

P1------------------------------------Quiz---------------------------------------P2
| |
Light Tower P1---------------------- |

Just one Arduino Uno should be able to handle this. You have the inputs A0 thru A5 that can be used for the buttons, (up to six) leaving the digital outputs 2 thru 13 available to drive LED's and solenoid drivers, etc.

Definitely use 1K pull-up resistors to 5V, so that the longer wire runs will have a low enough impedance that electrical noise shouldn't bother them. The buttons will then pull the pins to ground. (LOW when pressed, HIGH when not pressed.) It also wouldn't hurt to put .01 uf caps from the Uno input pins to ground, to help protect against radio signals causing false triggering. (Nearby 2-way radio, radio stations, or cell phones.) They will also provide some protection against static electricity.

I haven't looked at reading the whole Port A (the analog pins 0 thru 5) but it SHOULD be doable. That way, you grab all of the inputs at once. Comparing the bit values will tell you which button was pressed. Others here with more experience can tell you how that would work. (Or will tell me I'm all wet for suggesting it!) :wink:

You see, I'm pretty new at programming in "C" which the Arduino uses, but I have decades of experience with electronics, both analog and digital. :slight_smile:

God bless! :slight_smile:

kidpreacher5325:
It will be about 16 feet from the quiz circuit to each player control.

As the wires from your main Arduino to the buzzer buttons are relatively long, you might want to have a smaller Ohm value for the pull -down resistor to make the hardware fail-safe against wrong button readings.

For 16 feet long button cables better use 1K (1000 Ohm) or even 330 Ohm resistor as a pull-down resistor in the circuit! instead of 4K7 (4700 Ohm)!

[/quote]

For coding of buttons, first have a look into Arduino tutorials and example code

This tutorial is made for pull-down resistor button circuit:
https://www.arduino.cc/en/Tutorial/Button

The code provided in that tutorial is simply doing that:
. button is pressed ==> turn on the on-board LED (pin13 HIGH)
button is released ==> turn off the on-board LED (pin13 LOW)
[/quote]

Another example code for reacting on pressed button is provided in the IDE, please check menu option:

  • File - Examples - 02.Digital - StateChangeDetection

Can you make this example work with one of your push buttons?
The example code will just count how many times the button was pressed and each time a pressed button was detected it will switch between on and off and show in the serial monitor accordingly.

If you have at least one button working as it should, using the StateChangeDetection example program and a working circuit with a pull-down resistor, then we could speak about more code with two buttons at the same time.

Here is V0.3 now. I added a slow-down effect when near the top, and speed-up near bottom. (A little more realistic.)

The code is crude, but 100% effective. :slight_smile: The button portion will come in the near future...

// LED Carnival bell-ring thing effect. 
// A high-going signal will trigger the LED's to sequence like the weight
// on the carnival bell-ring thing to shoot up, then come down and "bounce"
// then the bottom LED stays lit until the sequence is triggered again.
// V0.2 - Button code to be added... this version currently just loops the display.
// V0.3 - Added variable speed to first ascent. Slower near top. Looks nice!

void setup()
{
  for (int x = 2; x < 14; x++)
  {
    pinMode(x, OUTPUT);
    digitalWrite(x, 0); //Set ALL pins 0 to start (All LED's OFF)
  }  
}

void loop() {
// ***  
// Button sense code will go here
// ***
  
  for (int x = 2; x < 12; x++) // LED's "shoot" up to ring bell...
  {
    int s=x*8; //Speed change variable based on sequence value
digitalWrite(x, 1);
delay(s-12); // Speed slows when near the top, faster near bottom.
digitalWrite(x, 0);
  }
  digitalWrite(12,1);
  delay(5);

  for (int x = 12; x > 1; x--) // LED's "slide" down and hit bottom
  {
    int s=x*8; //Speed change variable based on sequence value
digitalWrite(x, 1);
delay(s-10);  // Speed slows when near the top, faster near bottom.
digitalWrite(x, 0);
  }

  for (int x = 2; x < 6; x++) // LED's "bounce" up once...
  {
digitalWrite(x, 1);
delay(50);
digitalWrite(x, 0);
  }
  for (int x = 5; x > 1; x--) // LED's "slide" back down
  {
digitalWrite(x, 1);
delay(50);
digitalWrite(x, 0);
  }

  for (int x = 2; x < 5; x++) // LED's "bounce" up again...
  {
digitalWrite(x, 1);
delay(50);
digitalWrite(x, 0);
  }
  for (int x = 4; x > 1; x--) // LED's "slide" back down again and settle
  {
digitalWrite(x, 1);
delay(50);
digitalWrite(x, 0);
  }
digitalWrite(2,1);
delay(1500); // Keep looping for now
}

So, were you going to reset the ardiuno for each round? The game only works once and then you have to turn the board off and on?

What I'm saying is - you need to think about the overall flow of the game. Not just what happens in a round, but what happens between them. You are going to need a quizmaster "reset for next question" button.

Think in terms of what the sketch might be doing in any given moment, and how those tasks flow into one another.

 I would like it to light up 8-10 LED lights in sequence then ring a doorbell striker

I'd suggest Adafruit neopixels for this. You can get a strip of LEDs that can all be controlled with one wire. I think they sell the stuff by the meter. Way more feasible than attempting to run a loom of 8 wires. The cable run length may be an issue - neopixels use an 800kHz signal to control the leds.

For the doorbell striker, you will be looking at some sort of solenoid driver - you can't hook up a heavy coil directly to an ardiuno, the back-emf will fry it. An electronic noisemaker, however, is perfectly do-able, or a doorbell that already has the requisite bits.

Wire length for your inputs may be a problem - capacitance and whatnot, although if you use figure-8 doorbell wire I imagine it would work ok.

I've been working with him over on Facebook, and we're making progress with the project. I'm updating everyone here on the Forum, to keep you all in the loop. :slight_smile:

It will be "self-resetting". The code will simply wait for a pin to go HIGH, then it will run through the "animation" sequence, and then wait again for the pin to go high. It is using a string of LED's to visually emulate one of those "ring the bell" things at carnivals, where you whack the lever with a mallet, to make the weight fly up the pole to ring the bell.

I have all of that "animation" code working and posted, above.

For anyone that's interested, I've attached a simple schematic for an electromechanical bell-ringer that will "ding" when the top LED lights up.

He is working on a separate, hardware-based, "contestant button" system using some 7400 series chips. It will output a high signal on one of two lines, depending upon who hits their button first. Each of those outputs which will go to the Arduino that controls the animated bell-ringer for each contestant.

It should be a pretty cool thing once he gets it done. :slight_smile: The kids should love it!

(The 5-minute lockout on an EDIT is annoying, especially when the EDIT was forced by an upload error. Sigh)

Doorbell i'face.GIF

ok. I did figure out how to put a trigger. So now the PCB for the 2 player is working, and the two arduino boards play the light loop. Now all i need is the interface between the pcb and the inputs on the arduinos... I tried to hook the positive lead to the PCB Player indicator LED to the input pin on the arduino. does not read. tried a larger ground resistor, so it works if I "touch" the input lead to the LED, but if I make a firm connection, no luck. Will keep working. Thanks.

  // LED Carnival bell-ring thing effect. 
// A high-going signal will trigger the LED's to sequence like the weight
// on the carnival bell-ring thing to shoot up, then come down and "bounce"
// then the bottom LED stays lit until the sequence is triggered again.
// V0.2 - Button code to be added... this version currently just loops the display.
// V0.3 - Added variable speed to first ascent. Slower near top. Looks nice!
// VO.4 - Added trigger A0 as input
void setup()
{
  pinMode (A0, INPUT); // Set pin0 to read. Set pull down resistor..
  for (int x = 2; x < 14; x++)
  {
    pinMode(x, OUTPUT);
    digitalWrite(x, 0); //Set ALL pins 0 to start (All LED's OFF)
  }  
}

void loop() {
// ***  
// Button sense code will go here
// ***

  if (digitalRead (A0) == HIGH){
  for (int x = 2; x < 12; x++) // LED's "shoot" up to ring bell...
  {
    int s=x*8; //Speed change variable based on sequence value
digitalWrite(x, 1);
delay(s-12); // Speed slows when near the top, faster near bottom.
digitalWrite(x, 0);
  }
  digitalWrite(12,1);
  delay(5);

  for (int x = 12; x > 1; x--) // LED's "slide" down and hit bottom
  {
    int s=x*8; //Speed change variable based on sequence value
digitalWrite(x, 1);
delay(s-10);  // Speed slows when near the top, faster near bottom.
digitalWrite(x, 0);
  }

  for (int x = 2; x < 6; x++) // LED's "bounce" up once...
  {
digitalWrite(x, 1);
delay(50);
digitalWrite(x, 0);
  }
  for (int x = 5; x > 1; x--) // LED's "slide" back down
  {
digitalWrite(x, 1);
delay(50);
digitalWrite(x, 0);
  }

  for (int x = 2; x < 5; x++) // LED's "bounce" up again...
  {
digitalWrite(x, 1);
delay(50);
digitalWrite(x, 0);
  }
  for (int x = 4; x > 1; x--) // LED's "slide" back down again and settle
  {
digitalWrite(x, 1);
delay(50);
digitalWrite(x, 0);
  }
digitalWrite(2,1);
delay(1500); // Keep looping for now
}
}

I tied the two Arduino ground outputs to the ground on the 7400 contestant board, and it all works like a charm. Thank you Willie for all your help. Thank you to everyone else as well.

1 Like

if you wanted to use 3 arduinos, this could be done using the analogue values..

lets say you have pin A0 set to input, connect both external arduino's to this pin, (you could actually run as many buzzers as you wanted with this config)

now, program each arduino, to send an analogue signal to this pin when the button is pressed (ie set one to send a signal of say 0.3 v and the second to send a signal of 0.6 v (just examples))

Now on the main arduino, you only need to read one pin, A0 and take that value ie 0.3 or 0.6 to know which arduino hit the button first.

at the same time, send an additional signal to other arduino's from the players to cancel operation on the others..

you can complete the processes in the main arduino, and send out a signal to the corresponding arduino board, which can then be connected to its own LED matrix.

i think this is right.. please correct me if im wrong.. :slight_smile:

Bought two Arduino Relay Boards. I will tie one of these to the LED output on pin 11 which will activate the doorbell to ring the bell. Thank you all for your help and support.

1 Like