Construction and testing
Each bulb holder and push-button switch is mounted on a suitable box, with separate pair of wires for the bulb holder and the switch. GPIO board numbering is used throughout the project. Push-button switches’ wires are connected to GPIO pins 11, 13, 15, 16 and common to ground pin 9 of Raspberry Pi as shown in Fig. 1. A 5V, 4-channel solid-state relay module (refer Fig. 2), purchased from ebay.in, is connected to Raspberry Pi GPIO pins 18, 19, 21 and 23.
A 5V supply is given to relay module from Raspberry Pi. Coloured indicator bulbs (Bulb 1 through Bulb 4) are connected to the output of the relay board with 230V supply as shown in Fig. 1. System’s various connecting points are shown in Fig. 3.
Run the rasquiz.py Python script on the terminal by giving the command:
[stextbox id=”grey”]$ sudo python rasquiz.py[/stextbox]
The program executes from main subroutine. It prompts for user inputs like names of the teams and allowable time (in seconds) to respond to a question. Then it clears the screen and prompts you to continue or to stop. To continue the game, type 1 followed by pressing ‘Enter’ key. Raspberry Pi initialises the push-button switches’ pins as input and clears the solid-state relay pins to switch off the indicators.
As soon as contestants press their switches, names of the respective teams with their rank numbers get displayed on LCD screen, along with glowing of respective indicator bulbs. If no contestant presses the switch within specified time, all the switches’ pins get latched, so no more inputs will get registered and ‘Time Up’ message is displayed on screen.
By typing Ctrl+C keys at any time, the host or operator can stop the quiz without restarting the whole system or waiting till time up. When prompted, enter 1 to continue or 0 to quit the game.
Download source code: click here
Nitin Kisan Palte is a B.E. (instrumentation) and an electronics hobbyist, currently working as instrument mechanic in College of Agricultural Engineering and Technology, Dr Balasaheb Sawant Konkan Krishi Vidyapeeth, Dapoli