Mind-Controlled Gaming: Build Your Own BCI

by Upside Down Labs in Circuits > Sensors

220 Views, 1 Favorites, 0 Comments

Mind-Controlled Gaming: Build Your Own BCI

Untitled design(18).png

What if you could play video games without even touching a controller? No buttons, no joysticks—just your focus and your eye blinks. In this guide, we will show you how to build a Brain-Computer Interface (BCI) using the DIY Neuroscience Kit to translate EEG (brain) and EOG (eye) signals into keyboard commands.

Supplies

DIY Neuroscience kits (basic+pro) photos(6).png
DIY Neuroscience Kit - Basic.png

You just need a DIY Neuroscience kit which includes:

Hardware

  1. 1 x BioAmp EXG Pill
  2. 1 x BioAmp Cable v3
  3. 3 x Gel Electrodes
  4. 3 x Jumper Cables
  5. 1 x Arduino UNO EK R4 Minima
  6. 1 x Nuprep Skin Preparation Gel
  7. 1 x Wet wipe or Alcohol swab
  8. 1 x Laptop (not included)


Software

  1. Arduino IDE
  2. Arduino CMSIS-DSP Library


You can purchase any of the kit mentioned below from our online stores (Shipping Worldwide)

  1. DIY Neuroscience Kit - Pro (2025 Edition) ( | Tindie | Robu | Upside Down Labs Store)
  2. DIY Neuroscience Kit - Basic ( Tindie | Robu | Amazon India | Upside Down Labs Store)

How It Works

Before we build this project, let's understand the signals we are capturing:

  1. EEG (Electroencephalogram): When you focus, your brain produces Beta waves (13 to 30 Hz). The BioAmp EXG Pill is designed to detect and amplify these brainwaves.
  2. EOG (Electrooculogram): Moving or blinking your eyes creates biopotential signals which we will use to detect double and triple blinks.

The Arduino processes these raw signals. We programmed it as follows:

Action / Biological Signal Keyboard Command In-Game Result (e.g., Vector)
High Focus (Beta Waves) Right Arrow Key Move Forward / Accelerate
Double Blink (EOG Spike) Up Arrow Key Jump
Triple Blink (EOG Spike) Down Arrow Key Slide

Assembling BioAmp EXG Pill

F6RK031MJ0EEHZW.png

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

Controlling LEDs with your eeg signals.png

Connect BioAmp Cables to BioAmp EXG Pill as shown.

Skin Preparation

Controlling LEDs with your eeg signals.gif

Apply Nuprep Skin Preparation Gel on the skin surface where electrodes would be placed 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

Controlling LEDs with your eeg signals(1).gif
Controlling LEDs with your eeg signals(3).png

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.

Measuring EEG using Gel electrodes:

  1. Connect the BioAmp Cable to gel electrodes,
  2. Peel the plastic backing from the electrodes.
  3. Place the IN+ cable of the BioAmp EXG Pill on your forehead.
  4. Place IN- on the bony part behind the earlobe of one ear.
  5. Place REF on the bony part behind the earlobe of the other ear.

Connecting Arduino UNO EK R4 Minima

Controlling LEDs with your eeg signals(1).png

Connect the BioAmp EXG Pill to Arduino Uno R4 Minima as directed below:

  1. VCC to 5V
  2. GND to GND
  3. OUT to A0

Now connect Arduino UNO EK R4 Minima to the laptop using a USB cable.

⚠️Caution:

Always 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.

Install Arduino UNO R4 Boards

Untitled design(25).png
  1. Install Arduino IDE (https://www.arduino.cc/en/software) and launch it.
  2. Install Arduino UNO R4 Boards from Boards Manager. Make sure to click on YES when prompted to install

Install Arduino CMSIS-DSP Library

Untitled design(21).png
  1. Install Arduino CMSIS-DSP Library from the Library Manager.


Uploading Firmware

Untitled design(22).png
  1. Open the project link.
  2. Open a new sketch in arduino IDE and replace the existing code with this by pressing Ctrl + A and Ctrl + V
  3. Select the correct board and upload the code.

Now, test the functionality of all three controls by focus, double blinks and triple blinks. If you notice any inaccuracies or if a control isn't working, proceed to the debug steps.

DEBUGGING

Untitled design(19).png

Brainwaves vary from person to person, so the program is designed to be customizable.

To enable debug mode, Uncomment the #Define Debug by clicking on it and pressing CTRL + / or by removing the two slashes at the beginning of the line. Then, upload the code.

  1. Now, open the Serial monitor where you can see the Beta values and EOG envelope values.
  2. Now, focus at one point and notice your max beta value reached, set the BETA_THRESHOLD to less than half of the maximum value reached.
  3. Now, try blinking 2-3 times and monitor the maximum EOG envelope value reached. Set the BLINK_UPPER_THRESHOLD to the max envelope value noticed, and set BLINK_LOWER_THRESHOLD to 50% of the max value.
  4. Now, comment out the #define Debug line by pressing CTRL + / or by adding two forward slashes at the beginning of the line. Then, upload the code again.
  5. Now, test the controls again. If you’re still not satisfied, do the debugging steps again.

Game Play

Untitled design(18).png

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.

  1. To change the key mappings, set the FOCUS_KEY, DOUBLE_BLINK_KEY and TRIPLE_BLINK_KEY in the code to any keyboard key.
  2. For alphabets, just change the value to any alphabet like this:
FOCUS_KEY 'a'
  1. For any other keys visit this link to find the KEY names and change it accordingly like this:
FOCUS_KEY KEY_DOWN_ARROW

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.