Playing Pong… Telepathically!

How I used Brain-Computer Interfaces to play the game Pong without touching my keyboard…

Bagavan Marakathalingasivam
4 min readOct 24, 2021

A couple of weeks ago, I was playing the game pong against my younger brother, and it got me thinking about how iconic this game is. I mean, if you go up to anyone and show them this image, they’re probably going to know what it is (even if they haven’t played it before).

Becuase of that, there have been so many cool things people have done to play this game. From using reinforcemnt learning to get a computer to play better than humans, to recreating the game into a 1-dimensional one!

This got me thinking about another really cool way to play the game! What if I could, somehow, get my computer to move the paddle just by moving my hand a specific way? You’d probably call me a wizard, right?

Well… I guess I am!

This is how I used brain-comptuer interfaces to play the game Pong!

Uhhh… what’s a Brain-Computer Interface?

Visual Representation of the idea behind BCIs

A brain-computer interface (BCI) is a system that interprets brain signals from a person and sends that over to a computer or a machine. The machine will then perform a specific command depending on the type of signals it receives. There are different ways to read the brainwaves, but the most common way is by using a non-invasive method, which means you can read the brain signals without implanting anything into the brain, known as electroencephalography (EEG). EEGs use electrodes placed on the outside of your head to read different electrical signals.

Now, there are differnet types of signals you can collect:

  1. Electroencephalagrams (EEGs) — meaures brain signals
  2. Electrcardiagram (ECG) — measures heart signals
  3. Electromyography (EMG) — measures muscle signals

As you’ve probably guessed, we’re going to be using EMGs to detect the muscle movement in our hands.

If you want to learn more about the basics of BCIs, I would highly recommend checking out this article!

What BCI board are you going to use?

Image of OpenBCI’s Ganglion Board

The BCI I used for this project is OpenBCI’s Ganglion Board. This is a biosensing device that is used for collecting differnet types of electrical signals from anywhere! This means I not only will be able to detect my muscle signals but also my heart and brain signals as well (which will definiltey come in handy for future projects)!

Okay, so how are you going to connect the EMGs from the Ganglion board to the computer?

Getting inspired by a dinosaur…

So, a couple weeks before this project I built a similar one that allwos you to play the infamous no internet dino game while flexing my muscles!

Demo of Dino Project (I look sad, but I was just tired 😪)

To do this, I used Brainflow, an open-source python library, to read the EMG data and detect if I am flexing my arm or not. And if I am, the spacebar is pressed on my computer(getting the dinosaur to jump). Even though it sounds simple, it took almost 5 hours to complete the project! 😬

The Pong project is basically going to be the same thing only a bit more difficult, becuase instead of using only one channel (one arm), we will be using two (for both of our arms) with three electrodes each.

This is also why we’re going to use the same code, with a few changes:

  • Getting the code to read two channels instead of one (which surprisingly took longer than expected).
  • Pressing the down and up arrow keys depending on which arm we’re flexing (instead of just pressing the spacebar)

Feel free to check out the code here:

All that’s left is to do… is play!

I already spent hours working on this project, so I’m not going to spend even more trying to build the Pong game from scratch 😅 Instead, I’m using an online version of the game known as PeacePong — which lets you control both paddles at the same time (making it a lot easier when testing).

And without further ado… here’s a demo of the Pong Project in action!

Now it’s a bit hard to see my hands from that angle, but if you look closely you can see that when I flex one arm, the paddle goes up, and when I flex the other it goes down!

Final Thoughts

Wow, I can’t beleive we’re already at the end! This project took a while to complete, but the resutls were really promising. Even though it was just a fun new way to play pong, it allowed me to dive deeper into the field of BCIs and prepare me for future projects! The Pong project itself could also be used for so much more! With a few tweaks we can apply the same concepts to prostethic/bionic arms — when I close and open my hand, so does the robotic arm!

Can’t believe you’ve already made it to the end! Thanks for reading, and I hope you learned something new! If you have any questions, feel free to reach out to me on LinkedIn or Twitter!