Part of what excites me so much about EEG hacking is the idea that maybe I can control things with just my mind. Once you gain any experience at all with EEG signals, however, you realize just how hard a task that can be. So, start simple. Start with what’s easy. Build from there. With EEG, “easy” are Alpha waves. Alpha waves is nice a simple EEG waveform that shows up fairly strongly around 10 Hz. It is a great target for making one’s first brain controlled hack. And I just did it myself…check it out! It’s completely computer-free and feels like magic!
Electronics Setup
For this hack, I used the parts shown in the picture below. It’s an OpenBCI board sitting on an Arduino Uno (the Uno is completely hidden in this photo under the white OpenBCI board), a cheap peizo buzzer, and a basic red LED. I put a 330 ohm resistor in series with the LED and in series with the buzzer to limit the current (a practice recommended in all of the Arduino learning examples). Because I wanted to be completely computer-free, the whole thing is powered by a 9V battery adapter.
| OpenBCI plus Arduino Uno plus LED, Piezo Buzzer, and 9V Battery. |
EEG Setup
| My setup, including the colorful homemade adapter cable for attaching my two EEG electrodes. |
Arduino Processing Software
To detect Alpha waves in EEG signals, there are several things that you need to do:
- Filter to remove strong interfering signals (60 Hz and DC drift)
- Filter to focus on the frequencies of interest (in this case, Alpha are ~10 Hz)
- Decide if there is enough Alpha (and just Alpha) to activate the LED and buzzer
The full details of my signal processing chain is a long story that will get its own post. The Arduino’s limited bit depth (32-bits is the maximum data type) and limited speed with floating point operations means that you cannot use sharp filters. Instead, you have to use relatively gentle filters such as “biquad” filters (which are a form of 2nd order IIR filter). To generate the filter coefficients, I used code that I found here.
After doing my filtering, I then compute the RMS power of the signal. I simply square the single, apply a low-pass filter (another biquad from the code above), and take the square root. This gives you a running RMS estimate of the signal amplitude. Because of my filtering, this gives me a running estimate of the Alpha amplitude. I then light my LED and sound my buzzer based on the amount of Alpha energy.
Thinking Things to Action
So, with this setup, you’ve got yourself a self-contained device that responds to your brain waves. It doesn’t have to be just an LED or buzzer, either. It could be a robotic arm swinging a sword (to fight off pirates, of course), or a cool flashing hat for dance parties, or an animatronic flower that blooms with your thoughts. Or maybe you like the idea of getting this kind of neurofeedback to see what is happening when you meditate (change the filter from 10 Hz Alpha up to 20 Hz Beta). Or, maybe you could use it simply for weirding-out your friends and co-workers…what with the strange wires coming out of your head and all. There are so many possibilities.
To me, controlling things with your brain in this way seems a bit magical…but I made this thing myself, so I know that it’s not magic…it’s hacking!
Follow-Up: I extended this work to control a six-legged robot with my brain waves!