Introduction: Arduino Brain Wave Reader

This tutorial will show you how to very easily hack a game toy to a USB brain wave reader.

An example of the end result could be turning on an LED while concentrating and turning it off while relaxing.


Let's start.

Step 1: Parts

Hardware:

- USB cable
- Mindflex headset
- USB to TTL converter
- ATMega328
- 22pf Ceramic Disc Capacitor (x 2)
- Crystal Oscillator (I used 16MHz)
- Arduino to burn the sketch onto the ATMega328

Software:

A big thanks to all of those who developed the software listed below, without software this project wouldn't exist.

- Arduino Brain Library
- Processing
- Brain Visualizer
- ControlP5 Processing GUI Library

Tools:

- Soldering iron
- Wires
- Solder
- Hot glue gun

Step 2: Connecting to the RX Pin of the NeuroSky Board

Unscrew the side of the headset with the white button on top.

There should be 4 screws and opens very easily.

Once opened, you should see the NeuroSky board with a "QC Pass" sticker on it.

In the corner of the chip, you should see 4 pins.

Solder a SOLID CORE wire to the T pin on the board, ensuring you don't short circuit any other pins doing so.

Step 3: Removing the Battery Holder

On one side of the headset, there is a battery holder.

Remove the 4 screws to reveal the battery holder from the back.

In order for our extra wires, ATMega328, USB to TTL converter and USB cable to fit in we will have to remove it.

Once we've removed the battery holder the headset will be powered from the USB cable.

Cut the 2 wires going to the battery holder.

I've used a hot knife to smoothly cut the battery holder off, but you can also use your soldering iron. (Note: make sure you don't inhale the fumes and clean your soldering immediately after you're done cutting.)

Leave the battery door in place.

Step 4: Feeding the RX Cable to the Other Side of the Headset

The ATMega328 needs to receive data from the T pin of the NeuroSky board on the other side of the headset.

You will have to feed the wire coming from the T pin, through the strap of the headset to the other side.

Please note: this is the most difficult step of the entire project. You will need a lot of patience.

You will just have to keep trying, eventually you'll get the hang of it.

Also, check out the photo below to see how I did it.

Once you've done this, you can close up the side with the NeuroSky board again.

Step 5: Drilling a Hole for the USB Cable

In order for the USB cable to fit, we will have to drill a hole into the side of the headset.

Before you do this, make sure you strip the wires of the USB cable so you're ready to solder them.

Do a few test drills to see which drill bit you need and drill a hole into the side of the headset where the battery holder used to be.

Tie a knot into the USB cable for strain relief and feed it through the hole.

Ignore the electronics in the photo - I will come to that in a bit. (I didn't do everything in the right order - at least you will now!)

Step 6: Installing the Software & Burning the Sketch

Download the Arduino Brain Library software mentioned in the first step.

Insert your ATMega328 into the Arduino and burn the BrainSerialOut example onto it.

When you're done, take the chip out again and get ready to install it into the headset.

Example code:


#include <Brain.h>

    // Set up the brain parser, pass it the hardware serial object you want to listen on.
    Brain brain(Serial);

    void setup() {
            // Start the hardware serial.
            Serial.begin(9600);
    }

    void loop() {
            // Expect packets about once per second.
            // The .readCSV() function returns a string (well, char*) listing the most recent brain data, in the following format:
            // "signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma"  
            if (brain.update()) {
                    Serial.println(brain.readCSV());
            }
    }

Step 7: Soldering the ATMega328

First of all, this method is very unprofessional but due to the lack of space this is what I've done.

Get you're ATMega328 out and have a close look at it. Also observer the pin map image below, you should be able to identify the pins. You can use the half circle at the end to determine the orientation.

You will have to desolder the USB connector on the USB to TTL converter, as we'll be connecting it to the bare wires from the USB cable.

I've made a very amateuristic diagram for you below, solder everything as shown. If you follow the diagram step by step it shouldn't be difficult.

Once you've done this, make sure you solder the wire coming from the other side of the headset through the strap (from the NeuroSky board, pin T) to the RX pin of the ATmega328.

Step 8: Testing

Connect the USB cable, turn on the headset and open up the serial monitor.

You should see some readings on the screen, if not you should double check your connections.

The order of numbers is broken down into the following order:
“signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma”

If the test worked fine, you may continue by hot gluing everything in place.

The easiest way to do this, is to leave the battery door open and carefully place everything in side, putting tiny drops of hot glue on each component to keep it in place. When you're done, screw the battery door back on and continue to the final step.

Step 9: Visualizing

If you haven't already done so, download Processing, Brain visualizer & the controlP5 Processing GUI Library.

Start processing and ensure the library is included.

Plug in the headset, turn it on and load up the brain_grapher.pde sketch.

Close Arduino (not processing) and run the sketch.

You should end up seeing a variety of bars indicating different frequencies:

- Delta (1-3Hz): sleep
- Theta (4-7Hz): relaxed, meditative
- Low Alpha (8-9Hz): eyes closed, relaxed
- High Alpha (10-12Hz)
- Low Beta (13-17Hz): alert, focused
- High Beta (18-30Hz)
- Low Gamma (31-40Hz): multi-sensory processing
- High Gamma (41-50Hz)

Source: http://frontiernerds.com/brain-hack

The NeuroSky chip also does some processing and comes up with 2 values for "attention" and "meditation". You can use these values directly to control an LED or any other piece of electronics connected to your device.

Have fun, and don't take over the world ;)

Please post any questions in the comments, this is my first instructable so I might have forgotten something!
Tips & advice welcome too!

Arduino Contest

Participated in the
Arduino Contest