Playing Games With Your Mind Using Arduino Uno R4
by Upside Down Labs in Circuits > Sensors
54 Views, 0 Favorites, 0 Comments
Playing Games With Your Mind Using Arduino Uno R4
What if you could control games with nothing but your mind?
In this project, we’re using a BioAmp EXG Pill, which acts as a bio-potential signal amplifier to record brainwaves. An Arduino UNO R4 Minima is used for data acquisition and to analyze these brainwaves in real-time.
Note: This is an updated version of our existing project, Controlling Video Game Using Brainwaves (EEG)
This version features:
- No training or data collection required, start playing immediately
- Faster setup time (under 10 minutes vs several hours)
- Additional EOG-based controls for double blink and triple blink detection
- Real-time signal processing on Arduino UNO R4 using FFT
If you're interested in machine learning approaches for EEG signal classification,
Check out the original project linked above.
Before moving forward, let's get familiar with EEG, EOG, and BCI.
What is electroencephalography (EEG)?
Electroencephalography (EEG) is a method to record an electrogram of the spontaneous electrical activity of the brain. It is typically non-invasive, with the EEG electrodes placed along the scalp (commonly called "scalp EEG") using the International 10–20 system. EEG signals or brainwaves can be divided into 5 types as mentioned below:
- Delta - 0.2 to 3 Hz
- Theta - 3 to 8 Hz
- Alpha - 8 to 13 Hz
- Beta - 13 to 30 Hz
- Gamma - 30Hz and above.
For more information on the brain-waves, check the YouTube video: https://www.youtube.com/watch?v=2QOoR600dJY
What is Electrooculography (EOG)?
Electrooculography (EOG) is a technique for measuring the corneoretinal standing potential that exists between the front and the back of the human eye. The resulting signal is called the electrooculogram.
What is a Brain-Computer Interface (BCI)?
A brain-computer interface (BCI), sometimes called a brain-machine interface (BMI), is a direct communication link between the brain's electrical activity and an external device, most commonly a computer or robotic limb.
How does this game work?
This project combines EEG and EOG signals from a single channel to control games:
- Focus (EEG): When you concentrate, your brain generates beta waves (13-30 Hz). We detect this to control one key continuously.
- Double Blink (EOG): Two quick blinks trigger a second key press.
- Triple Blink (EOG): Three rapid blinks trigger a third key press.
The Arduino acts as a USB keyboard, sending keypresses to your computer based on these signals. You can play any games using double blink, triple blink, and focus.
Supplies
HARDWARE:
1 x BioAmp EXG Pill
1 x BioAmp Cable v3
3 x Gel Electrodes
3 x Jumper Cables
1 x Arduino Uno R4 Minima with USB Cable
1 x Nuprep Skin Preparation Gel
1 x Wet wipe
1 x Laptop (do not connect to charger while recording the EEG signals)
SOFTWARE:
Arduino IDE (https://www.arduino.cc/en/software)
Arduino CMSIS DSP Library (Available under Arduino IDE libraries)
You can get any of the kit mentioned below from our online stores (Shipping Worldwide)
- DIY Neuroscience Kit - Pro (2025 Edition) (DigiKey | Tindie | Robu | Amazon India | Upside Down Labs Store)
- DIY Neuroscience Kit - Basic (DigiKey | Tindie | Robu | Amazon India | Upside Down Labs Store) and Arduino Uno R4 Minima
- BioAmp EXG Pill (DigiKey | Tindie | Robu | Upside Down Labs Store), Nuprep Skin Preparation Gel (Tindie | Upside Down Labs Store) and Arduino Uno R4 Minima
- BioAmp EXG Pill - EXG Explorer Pack (Tindie | Mouser | Robu | Amazon India | Upside Down Labs Store), Nuprep Skin Preparation Gel (Tindie | Upside Down Labs Store) and Arduino Uno R4 Minima
Assembling BioAmp EXG Pill
If in case you received an unassembled BioAmp EXG Pill from a marketplace/distributor, then you may have to assemble it for this project by soldering the header pins and JST PH 2.0 connector, as shown in the diagram.
Connecting BioAmp Cable
Connect BioAmp Cables to BioAmp EXG Pill as shown.
Skin Preparation
Apply Nuprep Skin Preparation Gel on the skin surface where electrodes would be placed(refer to the image below) to remove dead skin cells and clean the dirt from the skin surface. After rubbing the skin surface thoroughly, clean it with a wet wipe or an alcohol swab.
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.
Complete guide on Skin Preparation: https://docs.upsidedownlabs.tech/guides/usage-guides/skin-preparation/
Electrode Placements
Let's understand the electrode placements before moving forward in this project. For recording EEG from the prefrontal cortex part of the brain, you have to place the electrodes on your forehead, specifically between Fp1 and Fp2 (refer to the International 10-20 system for recording EEG)
What is the International 10-20 system for recording EEG?
It is an internationally recognized method to describe and apply the location of electrodes in the context of an EEG exam or voluntary lab research. This method was developed to maintain standardized testing methods, ensuring that a subject's study outcomes (clinical or research) could be compiled, reproduced, and effectively analyzed and compared using the scientific method.
Measuring EEG using Gel electrodes:
- Connect the BioAmp Cable to gel electrodes,
- Peel the plastic backing from the electrodes.
- Place the IN+ cable of the BioAmp EXG Pill between the Fp1 and Fp2 positions
- Place IN- on the bony part behind the earlobe on one ear.
- Place REF on the bony part behind the earlobe of the other ear.
Connecting Arduino Uno R4 Minima
Connect the BioAmp EXG Pill to Arduino Uno R4 Minima as directed below:
- VCC to 5V
- GND to GND
- OUT to A0
Now connect Arduino Uno R4 Minima to the laptop using a USB cable.
Note:
BE VERY CAREFUL and follow the above diagram while making the connections between your BioAmp EXG Pill & Arduino Uno R4 Minima, especially the GND and VCC, or else it may damage the sensor.
Uploading Firmware
- Install Arduino IDE (https://www.arduino.cc/en/software) and launch it.
- Install Arduino UNO R4 Boards from Boards Manager. Make sure to click on YES when prompted to install additional software to flash your Arduino UNO R4 board on Windows.
- Install Arduino CMSIS-DSP Library from the Library Manager.
- Download Brain BioAmp Arduino Firmware GitHub repository and extract the folder.
- Open 08-bci-gaming.ino in Arduino IDE
- Before uploading, configure your game keys at the top of the code:
- #define FOCUS_KEY 'w' // Key held when focused
- #define DOUBLE_BLINK_KEY 'a' // Key pressed on double blink
- #define TRIPLE_BLINK_KEY 'd' // Key pressed on triple blink
- Select your board and COM port under the Tools menu and upload the code.
- Next, confirm on the Serial Monitor that focus, double blinks, and triple blinks are being detected.
If detection accuracy is poor, you can calibrate the system by following these steps:
- Enable Debugging:
- Uncomment // #define DEBUG at the top of the code to view envelope values.
- Determine BETA_THRESHOLD:
- Focus and note the maximum beta value achieved. Set BETA_THRESHOLD in the code to half of this maximum value.
- Set Blink Thresholds:
- Blink and observe the maximum EOG envelope value reached.
- Set BLINK_LOWER_THRESHOLD to a value slightly below this maximum EOG value
- Set BLINK_UPPER_THRESHOLD to a value slightly above it. This defines the operational range for blink detection.
- You can either comment out the #define DEBUG line or just leave it in before you upload the code.
- Check if the detection is good on the serial monitor. You might need to tweak again to get the best results. Repeat these steps to calibrate again for the best results.
Note: If an error occurs during code upload, try reconnecting the board and double-press the reset button before uploading again.
Playing Games With Your Mind
Once, the detection is good we can move on to controlling games
Testing your controls:
| Action | Required Motion | Resulting Key Press |
|---|---|---|
| Focus Detection | Focus your gaze on a single point. | The "Focus" key will be pressed and held. |
| Double Blink | Blink two times rapidly. | The "Double Blink" key will be pressed. |
| Triple Blink | Blink three times quickly. | The "Triple Blink" key will be pressed. |
Open any game in your browser, click on the game window, and start playing using your mind and blinks.
Note: Your laptop should not be connected to the charger as it can induce 50/60 Hz AC interference noise. While recording/visualizing the signals, it is recommended to maintain 5m distance from any AC appliances.
Whenever you blink, the beta‑wave reading dips sharply as eye movement artifacts momentarily overshadow the true beta signal.
Troubleshooting
If you experience issues with signal quality, then check the below link for tips for best signal acquisition:
https://docs.upsidedownlabs.tech/guides/troubleshoot/tips/index.html
Conclusion
What we've built isn't just a tech demo but it's a glimpse into a future of neurotechnology.
The possibilities are endless. What are you doing to make with it?
Let us know what you think about this project in the comment section below.
You can also mail us at support@upsidedownlabs.tech for any queries or issues while you make this project.