Fastest finger first systems are used in school, college and TV contests. The team which presses their push-button switch first is entitled to answer the query. When two or more teams press their push-buttons within a very small time gap, it becomes very difficult to identify the team that pressed the button first. In such cases, the decision can be biased due to human intervention.
The system presented here takes care of the aforesaid problem. This system can be used for a maximum of four teams in its present form. It is built around a Raspberry Pi board and a solid-state relay module.
Circuit and working
The Raspberry Pi runs a standard Raspbian Linux distribution with Wi-Fi dongle, installed GPIO library and software written in Python. Most of the coding has been done on the Raspberry Pi. Indicator bulbs are provided on contestants’ desks to know who pressed the push-buttons.
The HDMI output is connected to an LCD monitor to know the sequence of buttons pressed by the teams if two or more teams press the buttons almost simultaneously. The circuit can also be controlled via an SSH connection using VX ConnectBot software on an Android smartphone.
You may refer previous EFY issues for installation of standard Raspbian Linux distribution. Installation guide for Wi-Fi dongle on Raspberry Pi varies from dongle to dongle, so you may check it on Google.
Raspberry Pi GPIO library can be installed using following commands on the terminal window:
[stextbox id=”grey”]$ sudo apt-get install python-rpi.gpio
$ sudo apt-get install python3-rpi.gpio[/stextbox]
To access the above libraries add following lines to the Python script (rasquiz.py):
import RPi.GPIO as GPIO
termcolor module is used for simple formatting of text to colour, make bold, underline, highlight, etc. Install termcolor using command given below:
[stextbox id=”grey”]$ wget http://pypi.python.org/packages/
$ tar -xvzf termcolor-1.1.0.tar.gz
$ cd termcolor-1.1.0
$ sudo python setup.py install
Please refer the link below for more detail.
Download VX ConnectBot software from Play Store on Android smartphone. Start tethering or hotspot on smartphone and connect Raspberry Pi to it over a Wi-Fi network. After that start VX ConnectBot software and login to Raspberry Pi over SSH connection using [email protected] and default password (in this case raspberry). A terminal window will open on your Android phone from where you can run the Python script.
The input push-button switches (S1 through S4) are wired such that when pressed, its one end gets connected to GND (pin 9). The input pins are pulled up (internally) to 3.3V by the optional argument:
[stextbox id=”grey”]pull_up_down=GPIO.PUD_UP in GPIO.setup[/stextbox]
This means that, when you read the input value using GPIO.input, ‘False’ will be returned if the button is pressed. Each GPIO pin has software configurable pull-up and pull-down resistors.
The event_detected( ) function is designed to be used in a loop with other things, but unlike polling, it is not going to miss the state change of an input while the CPU is busy working on other things. This could be useful in something like a quiz game where there is a main loop listening and responding to GUI events on a timely basis. For example, falling-edge detection on a channel can be written as:
[stextbox id=”grey”]GPIO.add_event_detect(channel, GPIO.
GPIO.remove_event_detect channel is used to latch an input push-button once it is pressed. Various other commands and details can be found from the link http://sourceforge.net/p/raspberry-gpio-python/wiki/Inputs/
A solid-state relay (SSR) is an electronic switching device that switches on or switches off when a small external voltage is applied across its control terminals. An SSR has a sensor that responds to an appropriate input (control signal), a solid-state electronic switching device that switches power to the load circuitry and a coupling mechanism to enable the control signal to activate this switch without mechanical parts.
The relay may be designed to switch either AC or DC to the load. It serves the same function as an electromechanical relay, but has no moving parts. Solid-state relay details can be found from the link https://en.wikipedia.org/wiki/Solid-state_relay.
The code rasquiz.py written in Python language detects the push-button switches that are connected to the glowing bulbs, which show the fastest finger first contestants’ sequence, and to reset the system.