Playing Pong… Telepathically!

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!

--

--

--

15 y/o | Diving into neurotech + ai | 🥯🚚

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

7 rules to learn any complicated thing

PyTest Fixtures for Fun and Profit

Bash vs Z shell: A Tale of Two Command Line Shells

Realtek Pcie Gbe Family Controller Driver Windows 7 32 Bit

Episode 31: Powerpoint animations done in CSS

Thread Executors: New Ways of Multi-Threading in Java

Sparse Table -Range Query Technique

How to reduce AWS EBS cost by 20%

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bagavan Marakathalingasivam

Bagavan Marakathalingasivam

15 y/o | Diving into neurotech + ai | 🥯🚚

More from Medium

ADITYA: Reflections on Building India’s First Tokamak

Dark Aether’s Top 10 Games of 2021

NBA Hall of Fame from a statistical standpoint.

Cheating in Academia With Artificial Intelligence Writing