Quiz Game Buzzer with LCD 128×64
Build a Quiz Game Buzzer for 3 players with lights and sounds
I made this device because a good friend ask me for a buzzer for a quiz show.
The scenario is when one of the player presses it’s button faster than the others players, the LED of push button lights up saying the player is in control. It disables the other buzzers until the master releases the game by pressing a button on the main unit and the buzzer is ready for the next action.
Components Required:
- Atmega 328 pro mini
- LCD 128×64 (ST7920)
- 3 x LEDs
- Speaker
- 4 x push button
- 5v power supply
- 3 x 220Ω and 4 x 2.2 KΩ
Each player has a box, consisted of a push button and one LED. Total 3 boxes for 3 players.
The project can be extended easily for more players as well.
Each time when the push buttons are pressed, the speaker plays a little tune and number of the related box will be displayed on LCD.
Wiring:
LCD 128×64 operates in serial (SPI) mode.
Only 3 digital pins of the Arduino are required to get output on the LCD display.
E Clock –> D13
RW Data, MOSI –> D11
RS Chip Select –> D10
Libraries:
U8glib.h – graphic display control library,
OneWire.h – single bus protocol
Here the Source Code/Program:
/****************************************************************************** Mohammad Forgani (Forghanian Elyadarani) Sep 10, 2019 Description: Quiz Game Buzzer for 3 players with lights and sounds and LCD 128x64 www.forgani.com/electronics-projects/quiz-game-buzzer-with-lcd-128x64 ******************************************************************************/ #include "Wire.h" #include <OneWire.h> #include "U8glib.h" /* Define the SPI Chip Select pin */ U8GLIB_ST7920_128X64_1X u8g(10); // LCD operate in serial (SPI) mode. //assign buttons to pin (Analog) int but1 = A0; int but2 = A1; int but3 = A2; int butReset = A3; //assign LED to pins int led1 = 3; int led2 = 4; int led3 = 5; //initialize button state to 0 int but1State = 0; int but2State = 0; int but3State = 0; boolean player1 = false; boolean player2 = false; boolean player3 = false; //locked out state variables boolean pause = false; //assign speaker pin int sound = 6; // D6 int soundSecs = 250; // mSec void setup() { //Serial.begin(9600); Wire.begin(); //initialize button pins to input pinMode(but1, INPUT); pinMode(but2, INPUT); pinMode(but3, INPUT); pinMode(butReset, INPUT); //Serial.println("------- initialize output LEDs -----"); pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(LED_BUILTIN, OUTPUT); resetInputs(); pinMode(sound, OUTPUT); // output for buzzer delay(1000); } void loop() { int butResetState = digitalRead(butReset); if (butResetState == LOW && pause == true) { //Serial.println("pressed reset button"); digitalWrite(led1, LOW); digitalWrite(led2, LOW); digitalWrite(led3, LOW); player1 = false; player2 = false; player3 = false; digitalWrite(LED_BUILTIN, HIGH); tone(sound, 500, soundSecs); pause = false; } but1State = digitalRead(but1); but2State = digitalRead(but2); but3State = digitalRead(but3); if (but1State == LOW && pause == false) { //if 1 player press button //Serial.println("player 1 press button"); player1 = true; pause = true; tone(sound, 1100, soundSecs); } else if (but2State == LOW && pause == false) { //if 2 player press button //Serial.println("------- player 2 press button -----"); player2 = true; pause = true; tone(sound, 900, soundSecs); } else if (but3State == LOW && pause == false) { //Serial.println("------- player 3 press button -----"); player3 = true; pause = true; tone(sound, 700, soundSecs); } if (player1 == true) { //Serial.println("------- player 1 -----"); drawPlayerNr(1); digitalWrite(led1, HIGH); digitalWrite(led2, LOW); digitalWrite(led3, LOW); } else if (player2 == true) { //if 2 player press button //Serial.println("------- player 2 -----"); drawPlayerNr(2); digitalWrite(led2, HIGH); digitalWrite(led1, LOW); digitalWrite(led3, LOW); } else if (player3 == true) { //Serial.println("------- player 3 -----"); drawPlayerNr(3); digitalWrite(led3, HIGH); digitalWrite(led1, LOW); digitalWrite(led2, LOW); } if (pause == false) { //Serial.println("Koreanische Gemeinde"); startPage(); } } // display the number of Player on LCD void drawPlayerNr(int nr) { digitalWrite(LED_BUILTIN, LOW); u8g.firstPage(); do { char buf[1]; u8g.drawFrame(3,3,121,57); u8g.setFont(u8g_font_courB08); u8g.drawStr( 18, 35, "Nr."); u8g.setFont(u8g_font_fub49n); sprintf(buf, "%d", nr); u8g.drawStr(65, 56, buf); } while(u8g.nextPage()); } // display release page on LCD void startPage() { u8g.firstPage(); do { //Serial.println("firstPage"); u8g.setColorIndex(1); u8g.setFont(u8g_font_courB08); u8g.drawStr(5, 10, "Koreanische Gemeinde"); u8g.setColorIndex(1); u8g.drawBox(7,16,113,23); u8g.setColorIndex(0); u8g.setFont(u8g_font_helvB14); u8g.drawStr(12, 34, "Chung-Ang"); u8g.setColorIndex(1); u8g.setFont(u8g_font_courB10); u8g.drawStr(5, 57, "START ..." ); } while(u8g.nextPage()); } void resetInputs() { digitalWrite(led1, LOW); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(butReset, LOW); player1 = false; player2 = false; player3 = false; digitalWrite(LED_BUILTIN, LOW); digitalWrite(sound,LOW); // buzzer as off pause = false; clearLCD(); } void clearLCD(){ u8g.firstPage(); do { } while( u8g.nextPage() ); }
Leave a Reply