Playing Pong With Your Mind! DIY Brain Computer Interface W/ (Cerelog ESP-EEG) Using SSVEP BCI Tech
by Cerelog99 in Circuits > Wearables
73 Views, 0 Favorites, 0 Comments
Playing Pong With Your Mind! DIY Brain Computer Interface W/ (Cerelog ESP-EEG) Using SSVEP BCI Tech
Hi! 👋 I'm Simon, founder of Cerelog. I design EEG hardware.
I got into this because the technology is genuinely incredible. You can stick electrodes on someone's scalp, read the electrical activity of billions of neurons firing in concert, and decode what that person is paying attention to. In real-time. With a board that fits in your palm. That never stops being wild to me.
The problem was that for years, the hardware to actually do this either cost thousands of dollars or locked you into proprietary ecosystems that treated you like a customer instead of a builder. I saw that gap and built the Cerelog ESP-EEG: 8 channels, 24-bit ADS1299, ESP32, fully BrainFlow-compatible. Then I built a game to prove what it can do.
This Instructable shows you how to play Pong with your brain. Look left, paddle moves left. Look right, paddle moves right. No hands. No training. Works first session. (I'll explain why in Step 1. The neuroscience behind it is genuinely one of the coolest things I've ever encountered.)
If you've seen our previous Instructables, the general BCI overview or controlling a robotic hand with EMG, this is the next level. We teased SSVEP Pong in that first article. Here's the full walkthrough.
Here's a video of me playing it with a headset I hacked together out of foam and plastic. The video also covers the basics of SSVEP and general setup process: Video explainer!
The software is open-source. The schematic is published. If you've got the board and a way to get electrodes on the back of your head, you can have this running in about an hour.
⚠️ PHOTOSENSITIVE WARNING
This project uses flickering visual stimuli at different frequencies to evoke brain responses. If you or anyone nearby has a history of photosensitive epilepsy or seizures triggered by flashing lights, do not use this project. Consult a medical professional if you are unsure.
⚠️ ELECTRICAL SAFETY WARNING
The Cerelog board is not a medical device and lacks medical-grade isolation. NEVER use this device while your laptop or computer is plugged into a wall outlet. Always run on battery power only.
Supplies
Hardware
- Cerelog ESP-EEG Board — 8-channel, 24-bit ADS1299 ADC, ESP32 microcontroller
- USB-C data cable (must support data transfer, not just charging)
- Conductive electrode gel or paste (Ten20, Spectra 360, or similar)
- Ear clip electrodes (2x, for reference and bias — typically included with electrode kits)
- EEG headset (see options below)
- A laptop
Headset Options (Pick One)
The electrodes need to sit on the back of your skull, over the occipital lobe. How you get them there is up to you. Three options, in order of cost:
- DIY Foam Headset (~$10-20) — A flexible plastic headband, some foam, and cup electrodes. This is what I use in the demo video. It's ugly. It works. If you're just trying this out, start here.
- 3D-Printed OpenBCI Ultracortex — The Ultracortex Mark III/IV design files are open-source. We provide a 3D-printable adapter plate for the Cerelog board. More rigid and repeatable than foam, but you need a printer.
- OpenBCI Electrode Cap Kit ($999) — A professional cap with electrodes pre-positioned in the 10-20 system. It has far more electrode positions than the board's 8 channels, so you'll pick the ones closest to the occipital region. If you already have one of these or plan to do serious research, it works great. If you're just here for Pong, it's overkill.
Software
- Python 3.7+
- Git
- CMake and C++ build tools (for building BrainFlow from source)
- A code editor (VS Code works)
Full installation steps are in the Cerelog User Guide. We'll point you there in Step 3 rather than duplicating it here.
Wait, Your Brain Does WHAT?
Okay. This is the part that got me hooked on BCI in the first place.
Your visual cortex sits at the back of your skull, in the occipital lobe. When you stare at a light flickering at a steady frequency, say 10 Hz, billions of neurons in your visual cortex start firing at 10 Hz too. Locked in. Synchronized. This is called a Steady-State Visually Evoked Potential (SSVEP), and it's been known since not long after Hans Berger recorded the first human EEG in 1924. It's completely involuntary. Your brain will entrain to the flicker whether you want it to or not.
(Read that again. Your neurons literally synchronize to a blinking light on a screen. That's insane.)
Researchers started exploiting this for brain-computer interfaces in the 1970s and 80s, and since then SSVEP has become arguably the strongest non-invasive BCI paradigm we have. The competition isn't even close:
- Motor imagery (imagining moving your hand) requires weeks of training and tops out around 70% accuracy for most users
- P300 (detecting surprise responses) is reliable but slow, needing many repeated stimuli to get a clean signal
- SSVEP hits 90%+ accuracy, requires zero user training, and works first session. Recent research has pushed information transfer rates past 200 bits per minute, fast enough for real-time spellers, wheelchair control, and yes, Pong.
Here's how we use it. Our game puts two flickering targets on screen at different frequencies: 10 Hz on the left (cyan) and 15 Hz on the right (magenta). When you shift your gaze, the dominant frequency in your brain signal shifts too. The software detects which frequency is stronger and moves your paddle.
That's the whole trick. No neural network. No "imagine moving your left hand." You look at a blinking light and your visual cortex does the rest.
The Cerelog board picks up these microvolt-level signals through scalp electrodes, digitizes them at 250 samples/second with the ADS1299 (same ADC found in clinical EEG systems costing 10x more), and streams it all to your laptop over USB. A Python script handles the rest in real-time.
Strap in (Literally)
Now that you know the trick, let's get you wired up.
Plug In the Board
1. Optional: connect a 3.7V LiPo battery to the JST-PH connector. Red wire to RED marking, black to BLK. Don't reverse this.
2. Plug a USB-C data cable from the board to your laptop. Your laptop must be unplugged from the wall.
3. Green power LED comes on. Green status LED goes solid (not blinking), meaning firmware is loaded and ready.
Put the Headset On and Gel Up
Whatever headset you're using, the goal is the same: electrodes making solid contact with your scalp over the occipital lobe, the back and lower part of your skull.
Attach Reference and Bias Ear Clips
This part is non-negotiable for signal quality:
- Clip one ear electrode to your left earlobe, connect it to the BIAS pin. Generous gel.
- Clip another to your right earlobe, connect it to SRB1. Generous gel.
BIAS actively cancels common-mode noise: the 50/60 Hz hum your body picks up from every wire in the room. SRB1 is the reference that all channels measure against. Skimp on gel here and your data will be garbage.
Gel the Scalp Electrodes
Squeeze conductive gel into each electrode cup and work it through the hair to make skin contact. If the gel isn't touching scalp, you'll get noise or flatlines. This is the most annoying part of EEG and there's no shortcut.
The Boring (But Necessary) Software Part
I'm not going to re-write the installation guide here. I promise the next step is where it gets fun again. We maintain a detailed setup guide that covers Windows, macOS, and Linux:
Cerelog User Guide: Full Software Setup
The short version:
- Clone the Cerelog BrainFlow fork from GitHub
- Build from source with CMake
- Install the Python package: `pip install -e .`
- Install dependencies: `pip install matplotlib pyserial plotly dash scikit-learn "setuptools<82"`
Sanity Check Before the Game
Before you touch Pong, verify that data is actually streaming:
You should see a real-time plot of all 8 channels. Clench your jaw or blink hard and you should see the signal react. If channels are flat or pinned to one value, that's bad electrode contact. If the script can't find the board, check the green status LED, try a different USB port, try a different cable.
Once you see live, moving brain signals, you're good. Let's play.
The Moment of Truth, Calibrate and Play!
Hardware on your head. Software running. Brain doing its thing. Let's go.
Launch
(`python3` on macOS if needed.)
The script connects to your board, starts streaming, and fires up a web-based game. Open your browser to:
Calibration (About 24 Seconds)
The game runs a three-phase calibration automatically. Just follow the on-screen prompts:
Phase 1: "Focus on the LEFT flicker" (~7 seconds)
The left side of the screen flickers cyan at 10 Hz. Stare at it. Don't look away. The software is recording what your brain's "looking left" signal looks like.
Phase 2: "Focus on the RIGHT flicker" (~7 seconds)
Right side flickers magenta at 15 Hz. Same deal, stare at it.
Phase 3: "Look at the CENTER" (~7 seconds)
Both sides flicker. You look at the middle of the screen. This records your resting baseline.
After that, the software crunches the calibration data, computes your personalized left/right thresholds, gives you a 3-second countdown, and drops you into the game.
Playing
Once "PLAYING" appears:
- Look at the left flicker → paddle moves left
- Look at the right flicker → paddle moves right
- Look at the center → paddle holds position
You're the cyan paddle at the bottom. The AI is the magenta paddle at the top. Standard Pong, keep the ball in play.
Keyboard fallback: Press A (left) or D (right) to move the paddle manually. Useful for confirming the game works before trusting the BCI, or if you want to give your brain a break mid-session.
The Diagnostic Plots
Below the game canvas, two live charts update in real-time:
- PSD Plot. Power spectral density of your brain signal. When SSVEP is working, you'll see peaks at 10 Hz and/or 15 Hz. That's your visual cortex doing its thing.
- BCI Score. A bar showing the classifier's current left/right estimate, with threshold lines from calibration. Cyan (negative) = looking left. Magenta (positive) = looking right.
These are genuinely useful for debugging. If the PSD shows no peaks at the target frequencies, your electrodes are probably in the wrong spot or have bad contact.
What's Actually Happening Under the Hood
You don't need this step to play Pong. But if you're anything like me, you can't leave a black box unopened. This is the fun part.
The Full Pipeline
1. Screen flickers → retina → visual cortex. Neurons in the occipital lobe lock onto the stimulus frequency. Involuntary. Reliable. This is the SSVEP response, and honestly, the fact that we can exploit a fundamental property of human vision to build a control interface still amazes me.
2. Scalp → electrodes → ADS1299 → ESP32 → USB → laptop. The ADS1299 digitizes microvolt-level voltage fluctuations at 250 Hz with 24-bit resolution. This is the same ADC that sits inside clinical EEG systems costing 10-20x more. We just put it on a $350 board with an ESP32.
3. Filtering. Raw EEG is a mess: 50/60 Hz power line hum, muscle artifacts, DC drift, all stacked on top of the actual brain signal. The software cleans it up with a pipeline of detrend (remove DC offset), lowpass at 45 Hz, highpass at 5 Hz, notch filters at 50 Hz and 60 Hz, then rolling median smoothing. What survives is mostly the brain activity we care about.
4. CCA (Canonical Correlation Analysis). The core classifier. CCA takes your multi-channel EEG window and measures how well it correlates with reference sine waves at each target frequency (10 Hz, 15 Hz) and their harmonics. Whichever frequency template matches best is the one the software bets you're looking at. It's elegant: no training data required, no neural network, just linear algebra.
5. Thresholding. Calibration established where "looking left," "looking right," and "neutral" fall on the CCA score spectrum. The live score gets smoothed with an exponential moving average so your paddle doesn't jitter.
6. Paddle moves.
The whole chain, from photons hitting your retina to paddle movement on screen, runs in under a second. Every loop.
Why SSVEP for This Project
We covered the full comparison in Step 1, but the short version: SSVEP is the only BCI paradigm that works first session, no training, 90%+ accuracy. The tradeoff is staring at flickering lights, which is a bit intense. For a demo that needs to just work out of the box? No contest.
Troubleshooting
Board Not Detected
- Green status LED must be solid before running any script
- Full power cycle: disconnect USB-C, wait a few seconds, reconnect
- Make sure no other program is occupying the serial port
- Try a different USB port or cable (some USB-C cables are charge-only — this bites everyone at least once)
Noisy or Flat Signals
- Bad electrode contact is the cause 90% of the time. Reapply gel, especially to the BIAS and SRB1 ear clips
- Move away from power bricks, monitors, fluorescent lights
- Confirm your laptop is on battery, not mains
Paddle Doesn't Respond After Calibration
- Hit "Restart Game" and recalibrate — the first calibration sometimes catches a noisy window
- You need to actually look at the flicker with your eyes, not just point your head in that direction
- Check the PSD plot for peaks at 10/15 Hz. No peaks = no SSVEP = electrode problem
- Shift electrode positions by a centimeter or two — small movements make a big difference over the occipital lobe
Choppy Flicker
- SSVEP needs smooth, consistent stimulus timing. If your machine can't hold frame rate, the brain response degrades
- Close other GPU-heavy apps
- Make sure the browser tab isn't being throttled (some browsers throttle background tabs)
General Tips
- Dim the room. Higher flicker contrast = stronger SSVEP
- Sit still. Movement = muscle artifacts in the EEG
- Blink normally. Trying not to blink creates worse artifacts than blinking does
- Test with keyboard first. Use A/D to confirm the game works before blaming the BCI
You Just Played Pong With Your Brain. Now What?
You just played a video game with your brain. Not a metaphor. Your visual cortex generated frequency-locked oscillations, a 24-bit ADC captured them, a CCA classifier decoded your intent in real-time, and a paddle moved. That's a working brain-computer interface running on open-source software and a $350 board with a published schematic.
I think that's pretty cool.
Build on It
Pong is the demo, but the Cerelog board is a general-purpose 8-channel biosignal acquisition platform. With BrainFlow you've got bindings in Python, C++, Java, C#, R, MATLAB, and Julia. Some directions to take this:
- More SSVEP targets. More frequencies means more commands. Control a drone, navigate a menu, play a more complex game. The classifier scales.
- Other BCI paradigms. P300 spellers, motor imagery, event-related potentials.
- Research applications. Sleep staging, meditation studies, cognitive load measurement.
- Other biosignals. The board reads EMG and ECG too, not just EEG. (See our [robotic hand Instructable](https://www.instructables.com/Control-a-Robotic-Hand-With-Your-Muscles-and-ESP-E/) for an EMG demo.)
It's All Open Source
The BrainFlow fork, the Pong game, the filtering scripts, all of it is open source on GitHub:
https://github.com/shakimiansky/Shared_brainflow-cerelog
If you improve the electrode montage, build a new game, optimize the classifier, or find a bug, pull requests are welcome. This project gets better with every contributor.
Where to Buy & Connect
- Get the Board: cerelog.com, Currently on sale for $349.99 at the time this article was published
- Source Code & Files: GitHub
- Join the Community: Discord Server: (Link on the website)
- Questions? Email: support@cerelog.com
If you found this useful, please Favorite this Instructable and share it. And if you build something with the board, a new game, a research project, something we haven't thought of yet, we want to see it. Drop it in the comments or hit us up on Discord.