Skip to content

ibr0r0/brain-controlled-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  Brain-Controlled Games with EEG (OpenBCI)

This repo contains two browser-based brain-controlled games built with OpenBCI EEG signals:

  • game โ€“ Controlled by eye blinking (alpha wave spikes)
  • eye_game โ€“ Controlled by horizontal eye movement (based on two channels: N1P and N2P)

๐ŸŽฎ Game 1: game/ โ€” Blink-Based Flappy Bird

  • Blinking (or closing your eyes) generates a spike in alpha bandpower.
  • This spike causes the bird to flap (jump).
  • Gameplay is similar to Flappy Bird: avoid obstacles by blinking at the right time.

๐Ÿ” Signal Used

  • EEG Alpha band from a frontal electrode (e.g., Fp1 / Fp2)
  • Detects relaxed (eyes closed) state

๐Ÿ‘๏ธ Game 2: eye_game/ โ€” Eye Movement Control

  • Uses two EEG channels: N1P and N2P (left/right near eyes)
  • Movement is determined by comparing the signal difference: diff = N2P - N1P
  • Move a square left or right by moving your eyes

๐Ÿ” Signal Used

  • Raw signal difference between left and right eye channels
  • No ML, no alpha โ€” just real-time directional EEG

๐Ÿš€ How to Run

โœ… 1. Start OpenBCI GUI

  • Use Cyton board or compatible device
  • Set N1P and N2P as active channels
  • Go to Networking tab:
    • Stream: UDP
    • IP: 127.0.0.1
    • Port: 12345
    • Stream type: Band Power or Raw

โœ… 2. Start the UDP WebSocket server

From the root directory:

node server.js

It will show:

โœ… UDP server listening on port 12345

โœ… 3. Run the game in browser

For each game, do the following:

cd game        # or cd eye_game
npx live-server

Then visit: http://127.0.0.1:8080


๐Ÿงช Tips

  • Ensure electrodes are well placed near eyes for eye_game
  • Use game/ if you're focusing on alpha signals and blink control
  • You can tweak thresholds inside game.js and eye_game.js

๐Ÿง  Built by Eng. Ibr

๐Ÿšง This project is actively under development โ€” features, calibration methods, and signal processing logic are evolving rapidly.

About

Browser-based EEG games

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published