Interactive Quiz Game with Arduino
The Interactive Quiz Game with Arduino brings education and entertainment together in an engaging project. Using a LiquidCrystal display and buttons, this project challenges users with quiz questions, allowing them to select answers and receive immediate feedback.
The LCD screen provides a user-friendly interface, displaying questions and multiple-choice options. The game utilizes buttons for user input, making it interactive and accessible.
Component List:
Name | Quantity | Component |
---|---|---|
U1 | 1 | Arduino Uno R3 |
U2 | 1 | LCD 16 x 2 |
Rpot1 | 1 | 250 kΩ Potentiometer |
S1 S2 S3 S4 | 4 | Pushbutton |
R1 | 1 | 1 kΩ Resistor |
The circuit employs a LiquidCrystal display connected to pins 12, 11, 5, 4, 3, and 2 on the Arduino. Additionally, four buttons are connected to pins 6, 7, 8, and 9.
The buttons serve as input devices for users to select their answers during the quiz. The use of INPUT_PULLUP ensures a straightforward setup without the need for external resistors.
Arduino Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int buttonPins[] = {6, 7, 8, 9};
const int numButtons = sizeof(buttonPins) / sizeof(buttonPins[0]);
void setup() {
lcd.begin(16, 2);
lcd.print("Welcome to the");
lcd.setCursor(0, 1);
lcd.print("Quiz Game!");
delay(2000);
lcd.clear();
for (int i = 0; i < numButtons; ++i) {
pinMode(buttonPins[i], INPUT_PULLUP);
}
}
void loop() {
lcd.clear();
lcd.print("Question 1:");
lcd.setCursor(0, 1);
lcd.print("What is 2 + 2?");
delay(2000);
lcd.clear();
String options[] = {"1) 3", "2) 4", "3) 5", "4) 6"};
for (int i = 0; i < 4; ++i) {
lcd.setCursor(0, i + 2);
lcd.print(options[i]);
delay(2000);
lcd.clear();
}
int selectedAnswer = waitForButtonPress();
lcd.clear();
lcd.print("You chose: " + options[selectedAnswer - 1]);
lcd.setCursor(0, 1);
if (selectedAnswer == 2) {
lcd.print("Correct!");
} else {
lcd.print("Incorrect.");
}
delay(2000);
}
int waitForButtonPress() {
while (true) {
for (int i = 0; i < numButtons; ++i) {
if (digitalRead(buttonPins[i]) == LOW) {
return i + 1;
}
}
}
}
This Arduino-based quiz game offers a fun and educational experience. Users are welcomed with a greeting, presented with questions, and provided with multiple-choice options. The immediate feedback on their chosen answers enhances the learning experience.
The project is an excellent example of combining hardware components and programming logic to create an interactive and entertaining application.
As a starting point for Arduino enthusiasts, it showcases the potential for incorporating technology into educational games.