This project is a simple quiz-show buzzer system that uses a Raspberry Pi (RPi) connected to physical buzzers and communicates with a computer to run the main program. The Raspberry Pi detects when a buzzer is pressed, and the computer displays the results.
- Buzzers: Physical switches connected to the Raspberry Pi's GPIO pins.
- Buzzer 1: GPIO pin 17
- Buzzer 2: GPIO pin 22
- Buzzer 3: GPIO pin 27
- Communication: The Raspberry Pi and the computer are connected via Ethernet.
- IP Configuration:
- Raspberry Pi:
101.101.1.2 - Computer:
101.101.1.1
- Raspberry Pi:
- The Raspberry Pi runs a TCP server using the socket library, It listens for the request 'GET_STATES' and returns the HIGH or LOW states for GPIO pins 17, 22 and 27.
- The client on the computer sends request to the server and run the game logic for the buzzer system, presented to the user with a GUI made using pygame.
- A Raspberry Pi with the Raspberry Pi OS installed.
- A computer to run the GUI program.
- Ethernet cable for direct connection between the Raspberry Pi and the computer.
- Python 3 installed on both the Raspberry Pi and the computer.
- Connect each buzzer (switch) between 3.3V and the designated GPIO pins on the Raspberry Pi:
- Buzzer 1: GPIO 17
- Buzzer 2: GPIO 22
- Buzzer 3: GPIO 27
- Connect the Raspberry Pi and the computer using an Ethernet cable.
- Optional: Use the included STL file to 3D-print a buzzer housing designed for the KNX-1 switch. Ensure the buzzer is connected in parallel with a 10 kΩ resistor.
-
Assign the IP address to the network interface connected to the Raspberry Pi:
ip addr add 101.101.1.1/24 dev <your-interface>
Replace
<your-interface>with the name of your network interface (e.g.,enp3s0,eth0,wlan0). You can find the interface name using:ip link show
-
Add a route for the Raspberry Pi network:
ip route add 101.101.1.0/24 dev <your-interface>
-
Open the DHCP configuration file:
sudo nano /etc/dhcpcd.conf
-
Add the following lines at the end of the file:
interface eth0 static ip_address=101.101.1.2/24 static routers=101.101.1.1 static domain_name_servers=8.8.8.8Save the file and exit (Ctrl+O, Enter, Ctrl+X).
-
Restart the DHCP service:
sudo systemctl restart dhcpcd
- Navigate to the project directory containing
main.py. - Start the server by running:
python3 main.py server
- Navigate to the project directory containing
main.py. - (Optional) Create a Python virtual environment to isolate dependencies:
python3 -m venv venv source venv/bin/activate - Install any required Python libraries:
pip install -r requirements.txt
- Start the GUI by running:
or alternatively if you are running the program without running the server.
python3 main.py gui --physical_buzzers
python3 main.py gui
- You will be prompted to specify the number of players.
- For each player, you will enter:
- Name: The name of the player.
- Handicap: The time delay (in seconds) before their buzzer is activated leave empty if no handicap or 0 if you don't want answers before the question is finished.
- Sound Effect: The sound to play when the player buzzes in.
- GPIO Pin: The GPIO pin connected to the player's buzzer.
The program supports custom buzzer sounds for players. To add your own sounds:
- Place the sound files in the
buzzer_soundsfolder located in the project directory. - The program supports any file format compatible with
pygame.mixer, such as.mp3,.wav, etc. - When setting up players in the GUI, you can select these custom sounds for each player's buzzer.
- Host Reads Question: The host reads the question to the participants.
- Start Timer: Press the "Start Timer" button (hotkey:
t) to begin tracking the response time. - Player Buzzes: When a player buzzes in:
- The sound effect chosen for that player will play.
- The player's name will be displayed on the screen as the first to buzz.
- Correct Answer:
- Press the "Reset Buzzers" button (hotkey:
r) to allow all players to buzz in for the next question.
- Press the "Reset Buzzers" button (hotkey:
- Incorrect Answer:
- Press the "Wrong" button (hotkey:
y) to disable the incorrect player's buzzer for the current question. - The next player to buzz in gets the chance to answer.
- Press the "Wrong" button (hotkey:
- Handicap Handling: If a player has a handicap (e.g., 5 seconds), their buzzer will remain inactive until the timer reaches their handicap time.