Introduction: Control Dino Game Using Eye Blinks (EOG)
In this tutorial, you are going to make a game controller that will allow you to play the dino game (dinosaur game that appears in offline mode on Google Chrome) at your home just by blinking your eyes. To do so we will be detecting the EOG signals from eyes and take the eye blink as a trigger to emulate the space bar on the keyboard.
But before moving forward, let's understand a brief about Electrooculography (EOG):
What is Electrooculography (EOG)?
Electrooculography (EOG) is a technique for measuring the corneo-retinal standing potential that exists between the front and the back of the human eye. The resulting signal is called the electrooculogram.
Supplies
HARDWARE:
DIY Neuroscience Kit Pro (Upside Down Labs Store | Amazon India | Tindie | DigiKey )
The kit includes:
- BioAmp EXG Pill (Assembled)
- Arduino Uno with USB Cable
- BioAmp Cable (100cm)
- 3 x Jumper Cables
- NuPrep Skin Preparation Gel (25g)
- Wet Wipes x 10
- Repositionable Gel Electrodes x 3
- Boxy Gel Electrodes x 100
- Gel Electrodes (4 variants, 6pcs each)
- Muscle BioAmp Band (EMG Band)
- Brain BioAmp Band (EEG Band)
- Heart BioAmp Band (ECG)
- Electrode Gel (30ml)
- Servo Claw
- Muscle BioAmp Shield Kit
- Muscle BioAmp Shield v0.3 (Assembled)
- BioAmp Cable (100cm)
- Muscle BioAmp Band (EMG Band)
- BioAmp AUX Cable
- Gel Electrodes (4 variants, 6pcs each)
- STEMMA Cables x 6
- 9V Snap Cable
SOFTWARE:
Arduino IDE
Visual Studio Code
Python
About DIY Neuroscience Kit Pro:
It is like your Neuroscience Lab in a Box which lets you explore the world of neuroscience by recording various biopotential signals of your body (EEG, EMG, ECG, EOG) and making amazing HCI and BCI projects.
Step 1: Stack Muscle BioAmp Shield on Arduino Uno
Stack the Muscle BioAmp Shield on top of Arduino Uno properly.
Step 2: Connecting BioAmp EXG Pill
You can connect the BioAmp EXG Pill at A2 port of Muscle BioAmp Shield using the the 3 pin STEMMA cable as shown above.
Step 3: Connecting Electrode Cable
Connect the BioAmp Cable to BioAmp EXG Pill as shown in the video above.
Step 4: Skin Preparation
Apply Nuprep Skin Preparation Gel on the skin surface where electrodes would be placed to remove dead skin cells and clean the dirt from skin. After rubbing the skin surface thoroughly, clean it with a wet wipe.
About Nuprep Gel:
Nuprep skin preparation gel is a mildly abrasive, highly conductive gel that should be applied before placing the electrodes on the skin to improve measurements. When applied gently, it strips away the top layer of skin and moistens the underlying skin layer which reduces the skin impedance with minimal skin irritation and discomfort.
Step 5: Electrode Placements
- Connect the BioAmp Cable to gel electrodes,
- Peel the plastic backing from electrodes
- Place the IN+ and IN- cables on the forehead and below the eye & REF (reference) at the bony part, on the back side of your earlobe as shown above.
Step 6: Download Arduino IDE
Download the Arduino IDE from the link given below:
https://www.arduino.cc/en/software
After downloading, connect the Arduino to your laptop using the USB Cable
IMPORTANT: Make sure to install Arduino IDE version 1.8.19 (Legacy IDE). If you download Arduino IDE version 2 then you will not be able to visualize the signals appropriately as it moves very fast (in other words the data points plotted in a particular time frame is very less)
Step 7: Coding Time!
Download the GitHub repository given below and unzip it:
Eye BioAmp Arduino Firmware: https://github.com/upsidedownlabs/Eye-BioAmp-Arduino-Firmware
Go to the folder 6_EMGDinoGame, open the arduino sketch 6_EMGDinoGame.ino in Arduino IDE.
Go to tools from the menu bar, select board option then select Arduino UNO. In the same menu, select the COM port on which your Arduino Uno is connected. To find out the right COM port, disconnect your Arduino UNO board and reopen the menu. The entry that disappears should be the right COM port.
Now upload the code.
IMPORTANT: Make sure your laptop is not connected to a charger and sit 5m away from any AC appliances for best signal acquisition.
Step 8: Testing the Connections
In Arduino IDE, go to tools from the menu bar, click on serial plotter to open it.
Press the SW1 button on Muscle BioAmp Shield. Now you’ll see green LED glowing on the LED bar.
Blink your eyes to detect them on the serial plotter.
If this works perfectly, then we can go ahead to next steps.
Step 9: Running Python Script
Open Visual Studio Code, click on File < Open folder to open the folder 6_EMGDinoGame
Open the terminal, and ensure that the path is configured to the location of the requirement.txt file.
To install all the modules that are required to run the Python script, write the given command in the terminal:
pip install -r requirements.txt
Open control.py and change the COM Port in the code (line 13) as per the COM Port you selected in Arduino IDE. Save the file by clicking CTRL + S.
# Arduino serial port interface
ser = serial.Serial('COM4', 115200, timeout=1)
Run the Python script control.py by writing the given command in the terminal:
python control.py
After running the script you will see Blink Now prompt.
Now press the SW1 button on the Muscle BioAmp Shield to start the game (The green LED will glow which indicates that the game controller is working).
So whenever you blink, it should give the feedback as jump as shown in the image above which means everything is working properly and you can now start playing the dino game.
Step 10: Play the Game
Open the Dino Game by clicking the link below:
Dino Game: https://chromedino.com/
Now you just have to blink your eyes instead of using the space bar to play the game. HAVE FUN and comment down your best scores here :)
Feel free to ask any questions in the comment box below. You can also mail us at support@upsidedownlabs.tech for any kind of support while making this project.