loading

A good friend of mine who's a teacher was doing quizzes in her class making students compete to answer questions... resulting in them complaining they raised their hands before the others.
I decided to give her this quiz show type buzzer for Christmas to solve her problems.

When one of the players press it's button (the fastest player wins this), the led of the right colour lights up saying he's in control... and no other buttons from the other players work, until the master of the game decides if the answer is good or not by pressing a little button on the main unit, giving a point or not to the player in control.

If you have any questions, comments, constructive criticism... don't hesitate to write :)

If you like my build, please like the video on YouTube and subscribe, it would be nice :)

P.S. There is a little problem with the display that I couldn't figure out how to solve. When playing a tune, the display doesn't light up anymore, like if no current goes to it anymore... anybody has an idea what the problem could be or how to fix it in code ? See the video if you don't understand what I mean.

Step 1: Components

Step 2: The Plan

Sorry for my writing... I know it's not a very professional plan, but if I have more time I will make a better one and replace it... feel free to ask me anything about it if it's not clear ;)

Step 3: The Prototype

I've decided to try my idea with an Arduino prototype.

The different buttons are for each "team" and for the master of the game to accept or reject an answer, giving the point to the team answering the question or not.

The leds lit up to know which team can currently answer.

The speaker plays a little tune... but it's not amplified, so it's not very loud.

The display shows the current score for each teams.

Step 4: The Code

So... I'm including my code, but I'm not explaining it... and yes I know there is no comments... if you have questions, feel free to ask me, but I didn't do this to make a programming tutorial.

First you need to include "pitches.h"... but to be able to include it, you need to get it from here... Arduino Tone Tutorial

#include "pitches.h"

Then let's define some arrays to help ourselves for later when we need to use the 8 digits 7 segments display

// array to activate particular digit on the 8x7segment module<br>// it is the common anode of 7 segment
byte digit[8] = { 
  0b10000000,  //digit 1 from right
  0b01000000,  //digit 2 from right
  0b00100000,  //digit 3 from right
  0b00010000,  //digit 4 from right
  0b00001000,  //digit 5 from right
  0b00000100,  //digit 6 from right
  0b00000010,  //digit 7 from right
  0b00000001   //digit 8 from right                                         
};
//array for decimal number, it is the cathode, please refer to the datasheet.
//therefore a logic low will activete the particular segment
//PGFEDCBA, segment on 7 segment, P is the dot
byte number[12] = {
  0b11000000,  // 0
  0b11111001,  // 1
  0b10100100,  // 2
  0b10110000,  // 3
  0b10011001,  // 4
  0b10010010,  // 5
  0b10000010,  // 6
  0b11111000,  // 7
  0b10000000,  // 8
  0b10010000,  // 9  
  0b01111111,  //dot                  
  0b11111111   //blank
};

We should also define some constants that will help us identify input and output pins later in the code

const int blueLEDPin = 12;
const int greenLEDPin = 11;
const int redLEDPin = 10;
const int yellowLEDPin = 9;

const int teamPinDiff = 5;  //to help with computations later<

const int blueButton = 17;
const int greenButton = 16;
const int redButton = 15;
const int yellowButton = 14;
const int acceptButton = 18;
const int refuseButton = 19;

const int speakerPin = 8;

const int latchPin = 7;  //connect to RCK of 8x7segment module 
const int clockPin = 6;  //connect to SCK of 8x7segment module 
const int dataPin = 5;  //connect to DIO of 8x7segment module

const int multiplexDelay = 1;

const int dotNumber = 10;
const int blankNumber = 11;

We also need to keep some variables to know what's going on in the program

int currentTeam = 0;
int blueScore = 0;
int greenScore = 0;
int redScore = 0;
int yellowScore = 0;byte blueDigit1 = number[blankNumber];
byte blueDigit2 = number[0];
byte greenDigit1 = number[blankNumber];
byte greenDigit2 = number[0];
byte redDigit1 = number[blankNumber];
byte redDigit2 = number[0];
byte yellowDigit1 = number[blankNumber];
byte yellowDigit2 = number[0];

Then we setup the pin modes and the display

void setup()
{  
  pinMode(blueLEDPin, OUTPUT);
  pinMode(greenLEDPin, OUTPUT);
  pinMode(redLEDPin, OUTPUT);
  pinMode(yellowLEDPin, OUTPUT);
  pinMode(blueButton, INPUT);
  pinMode(greenButton, INPUT);
  pinMode(redButton, INPUT);
  pinMode(yellowButton, INPUT);
  pinMode(acceptButton, INPUT);
  pinMode(refuseButton, INPUT);
  pinMode(speakerPin, OUTPUT);
  
  digitalWrite(blueLEDPin, LOW);
  digitalWrite(greenLEDPin, LOW);
  digitalWrite(redLEDPin, LOW);
  digitalWrite(yellowLEDPin, LOW);
  
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  digitalWrite(latchPin, HIGH);
}

And we create the loop function that will run after setup

void loop() 
{
  ProgramLoop();
  WriteScore();
}

As you see, I've created functions to separate my code a bit better... so let's create those functions

void ProgramLoop()
{
  if (currentTeam == 0) {
    if (digitalRead(blueButton) == HIGH) {
      currentTeam = blueLEDPin;
      PlayAnswerBlue();
    }
    else if (digitalRead(greenButton) == HIGH) {
      currentTeam = greenLEDPin;
      PlayAnswerGreen();
    }
    else if (digitalRead(redButton) == HIGH) {
      currentTeam = redLEDPin;
      PlayAnswerRed();
    }
    else if (digitalRead(yellowButton) == HIGH) {
      currentTeam = yellowLEDPin;
      PlayAnswerYellow();
    }
  }
  else
  {
    digitalWrite(currentTeam, HIGH);
    if (digitalRead(currentTeam + teamPinDiff) == LOW) {
      if (digitalRead(acceptButton) == HIGH) {
        PlayAccept();
        IncrementScore();
      }
      else if (digitalRead(refuseButton) == HIGH) {
        PlayDeny();
        ResetState();
      }
    }
  }
}
void ResetState()
{
  currentTeam = 0;
  digitalWrite(blueLEDPin, LOW);
  digitalWrite(greenLEDPin, LOW);
  digitalWrite(redLEDPin, LOW);
  digitalWrite(yellowLEDPin, LOW);
}
void IncrementScore()
{
  switch (currentTeam) {
  case blueLEDPin:
    blueScore++;
    if (blueScore > 9) {
      if (blueScore > 99) {
        blueScore = 0;
      }
      blueDigit1 = number[blueScore / 10];
    }
    blueDigit2 = number[blueScore % 10];
    break;
  case greenLEDPin:
    greenScore++;
    if (greenScore > 9) {
      if (greenScore > 99) {
        greenScore = 0;
      }
      greenDigit1 = number[greenScore / 10];
    }
    greenDigit2 = number[greenScore % 10];
    break;
  case redLEDPin:
    redScore++;
    if (redScore > 9) {
      if (redScore > 99) {
        redScore = 0;
      }
      redDigit1 = number[redScore / 10];
    }
    redDigit2 = number[redScore % 10];
    break;
  case yellowLEDPin:
    yellowScore++;
    if (yellowScore > 9) {
      if (yellowScore > 99) {
        yellowScore = 0;
      }
      yellowDigit1 = number[yellowScore / 10];
    }
    yellowDigit2 = number[yellowScore % 10];
    break;
  }
  ResetState();
}
void WriteScore()
{
  display8x7segment(digit[0], number[dotNumber]);
  display8x7segment(digit[0], blueDigit2);
  display8x7segment(digit[1], blueDigit1);
  display8x7segment(digit[2], number[dotNumber]);
  display8x7segment(digit[2], greenDigit2);
  display8x7segment(digit[3], greenDigit1);
  display8x7segment(digit[4], number[dotNumber]);
  display8x7segment(digit[4], redDigit2);
  display8x7segment(digit[5], redDigit1);
  display8x7segment(digit[6], number[dotNumber]);
  display8x7segment(digit[6], yellowDigit2);
  display8x7segment(digit[7], yellowDigit1);
}

void display8x7segment(byte digit, byte number)
{
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, digit); // clears the right display
  shiftOut(dataPin, clockPin, MSBFIRST, number); // clears the left display
  digitalWrite(latchPin, HIGH);  
  delay(1);
}
void PlayAnswerBlue() 
{
  display8x7segment(digit[7], number[blankNumber]);
  beep(speakerPin, NOTE_C5, 100);
  delay(25);
  beep(speakerPin, NOTE_C5, 100);
  delay(25);
  beep(speakerPin, NOTE_C5, 100);
}

void PlayAnswerGreen() {
  display8x7segment(digit[7], number[blankNumber]);
  beep(speakerPin, NOTE_D5, 100);
  delay(25);
  beep(speakerPin, NOTE_D5, 100);
  delay(25);
  beep(speakerPin, NOTE_D5, 100);
}

void PlayAnswerRed() {
  display8x7segment(digit[7], number[blankNumber]);
  beep(speakerPin, NOTE_E5, 100);
  delay(25);
  beep(speakerPin, NOTE_E5, 100);
  delay(25);
  beep(speakerPin, NOTE_E5, 100);
}

void PlayAnswerYellow() {
  display8x7segment(digit[7], number[blankNumber]);
  beep(speakerPin, NOTE_F5, 100);
  delay(25);
  beep(speakerPin, NOTE_F5, 100);
  delay(25);
  beep(speakerPin, NOTE_F5, 100);
}

void PlayAccept() {
  display8x7segment(digit[7], number[blankNumber]);
  beep(speakerPin, NOTE_C5, 75);
  delay(10);
  beep(speakerPin, NOTE_D5, 75);
  delay(10);
  beep(speakerPin, NOTE_E5, 75);
  delay(10);
  beep(speakerPin, NOTE_G5, 75);
  delay(10);
  beep(speakerPin, NOTE_E5, 75);
  delay(10);
  beep(speakerPin, NOTE_G5, 75);
  delay(10);
  beep(speakerPin, NOTE_C6, 75);
}

void PlayDeny() {
  display8x7segment(digit[7], number[blankNumber]);
  beep(speakerPin, NOTE_A4, 1000);
}

void beep (unsigned char speakerPin, int frequencyInHertz, long timeInMilliseconds)
{
  int x;      
  long delayAmount = (long)(1000000/frequencyInHertz);
  long loopTime = (long)((timeInMilliseconds*1000)/(delayAmount*2));
  for (x=0; x < loopTime; x++)
  {
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(delayAmount);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(delayAmount);
  }
}

Step 5: The Buttons

I made the buttons with some big coloured buttons and some speaker cables... you can use whatever kind of cables you want. I also added connectors to make it easier to transport by removing it from the main unit.

Step 6: The Main Unit

Here I've soldered everything together on the board and to all the components.

Then I've put everything in a wooden box that I built with the help of my dad, it's custom made for this project and took a lot of time to built, but I'm really happy with the final product.

Oh and the Arduino has been replaced by an ATmega328 chip with a 16mhz ceramic resonator to save on cost and on space.

I'm also using a 5V power supply to power the whole thing... since the power should be more or less constant, I made the bet of not using a voltage regulator, but it would probably be safer to use one.

Step 7: The Finished Product

Here's the Game Show Buzzer in action :)

Step 8: Here's How It Plays

If you like my build, please like the video on YouTube and subscribe, it would be nice :)

<p>good job mr......i,m from indonesia student..... i,m coding mr...thank you.......jokosantoso592.js@gmail.com.......mr.clapoti is the best.....please coding i like</p>
<p>where should i connect teamPinDiff? thanks!</p>
It is just to help with the algorithm, so you can read a pin according to a team number... it's to make the code smaller and not repeat too mnay things.
<p>Wonderful result. Seems to be very useful for this kind of games.</p>
<p>Thanks :)</p>
<p>I'm in the process of making this for my own classroom. I just wanted to say awesome job and thanks for the detailed instructions! One quick thing I noticed, there is a copy/paste issue in the first block of code right before the &quot;//array for decimal number&quot; line. I figured I'd point this out to help avoid confusion. Thanks again!</p>
Thank you, I just fixed it :)
<p>My teacher saw this and asked me out of 180 student and a 12 year old kid to make this for her.</p>
<p>That sounds cool, good luck :)<br>And if you have any questions, let me know.</p>
<p>I was wondering how I could change it so that there would eight boxes instead of four can you please help, thanks. : )</p>
<p>Hi, I'm interested about this project. Btw, I'm still new with Arduino, so looking to this project, I want to try and improve my Arduino skill. I just want to ask, the code you had provided here, I just can copy it, and compile it together? No need extra alteration, except the tone?</p>
<p>You don't need to change anything, if you do the electronics like I did and plug everything on the same pin, it should work correctly.<br>Ask me if you have other questions :)</p><p>Good luck :)</p>
<p>ok. im nt worried about the wiring. just the code, so, i just copy from the first one, and keep following until i get to bottom? is it like that?</p>
<p>Yeah it should work like that :)</p>
<p>I need a little help with the code: error: 'display' was not declared in this scope and the last line of the code: for (x=0;x</p><p>sketch_sep07f.ino: In function 'void beep(unsigned char, int, long int)':</p><p>sketch_sep07f:305: error: expected `;' at end of input</p><p>sketch_sep07f:305: error: expected primary-expression at end of input</p><p>sketch_sep07f:305: error: expected `)' at end of input</p><p>If someone can help that would be great</p><p>Thanks</p>
<p>So I added the missing code part and saw some formatting errors, so I fixed that too.</p><p>Let me know if everything works :)</p><p>Good luck and thanks for commenting and letting me know something was wrong.</p>
<p>For the last line of code, I didn't notice before, but it seems like I made a copy/paste mistake, I didn't copy all the code from my program, will fix it when I get home later today.<br>For the 'display' was not declared error, I'm not sure where the error could be, the only 'display' I can find is the function &quot;display8x7segment&quot; and the call to this function...</p>
Clapoti<br>The display error is: display digitalWrite(latchPin, HIGH); <br> <br>void display8x7segment(byte digit, byte number){<br> digitalWrite(latchPin, LOW); <br> shiftOut(dataPin, clockPin, MSBFIRST, digit); // clears the right display shiftOut(dataPin, clockPin, MSBFIRST, number); // clears the left<br> display digitalWrite(latchPin, HIGH); // display not declared<br> delay(1);<br>Thanks
<p>It's just because &quot;display&quot; is part of the comment on the previous line...<br>Like this...<br><br>void display8x7segment(byte digit, byte number)</p><p>{</p><p style="margin-left: 20.0px;">digitalWrite(latchPin, LOW); <br>shiftOut(dataPin, clockPin, MSBFIRST, digit); // clears the right display shiftOut(dataPin, clockPin, MSBFIRST, number); // clears the left display digitalWrite(latchPin, HIGH); // display not declared<br>delay(1);</p>
<p>to make this more quiz show like I would love the controller to be able to choose double points rounds and loss of points rounds maybe through 2 simple toggle switches. besides that this is perfect.</p>
<p>Yeah that would be an easy improvement to do, nice idea :)</p>
This would be great for studying!!
<p>Yeah it is :)<br>My friend uses it in her class to quiz her students to make them practice the subjects :)<br>Glad you like it</p>
<p>Excellent! One of my favorite microcontroller projects to date. I want this.</p>
<p>Thanks, it's very nice to know that, especially that it's my first project of the sort.<br>It's not so hard to make... it just takes time :)<br>You also have nice projects by the way :)</p>
<p>That's fantastic! Very well done. The end product looks really nice. :D</p>
<p>Thank you very much :)<br>You also have great instructables, I love cooking so I'll try some for sure :D</p>
<p>How does it handle multiple pushes from the 4 buttons.. The video shows you pressing one button at a time.. Excellent attention to build quality though..</p>
<p>I added the text in the intro, I forgot to explain that part.</p><p>&quot;When one of the players press it's button (the fastest player wins this), the led of the right colour lights up saying he's in control... and no other buttons from the other players work, until the master of the game decides if the answer is good or not by pressing a little button on the main unit, giving a point or not to the player in control.&quot;</p>
<p>Cool deal.. </p>
<p>Thanks :)</p>

About This Instructable

21,219views

259favorites

License:

More by Clapoti:Arduino Binary Clock Wooden Puzzle Modular Electronics Prototyping Board Arduino RGB LED Strip Controller 
Add instructable to: