Introduction: Control a Computer With Your Mind!

Picture of Control a Computer With Your Mind!

Controlling your computer with your mind definitely seems like something still out of a sci-fi movie, but mind control is actually a relatively easy and cheap thing to accomplish. Using a cheap EEG toy, let's use the power of our mind to send commands to our computer. There’s a lot to do, so let’s start tinkering

Step 1: Watch the Video

This Instructable is based on a video series I did a while back. So for those of you that are video learners, please check it out and support my channel! For those of you that like the written step by step instructions, on to step two!

Step 2: Gathering the Parts

Picture of Gathering the Parts

Here's the parts you need and the approximate prices at the time of writing this post.

  1. Star Wars Force Trainer (or other EEG headset) = $40
  2. Arduino Uno = $7
  3. Hard drive jumper = scavenged for free (or 0.35 if you can't scavenge)

Total is approximately $50

Step 3: Disassemble the Force Trainer

Picture of Disassemble the Force Trainer

In order to use the brain waves that the Star Wars Force Trainer receives, we need to take it apart and connect to it. All we will need is the headset. The ball tube will not be used for this project. One of the best things about this project is that it still functions as a toy even after you’ve hacked it. So you don’t have to worry about not being able to play with it again once you’ve taken it apart.

  1. On the headset, remove the batteries and the screws that hold the top plate on.
  2. Locate the Neurosky EEG board, as pointed out on the left.
  3. Solder a wire to the T-Pin on the EEG board.
  4. Solder a second wire to the Ground terminal on the battery case.
  5. Drill or carve a small hole in the plastic casing that the wires can run through.
  6. Put a small dab of hot glue on the wires after running them through the hole to hold them in place.

Now you’re headset should be ready for outputting data! Replace the batteries and ensure everything is still working, and then screw the top casing back on. The next part is connecting an Arduino to the headset to collect the data!

Step 4: Connecting the Arduino

Picture of Connecting the Arduino

The next step is to get the EEG data from the headset onto our computers. In order to do this, we need something that will convert it from raw data coming from wires to readable data coming through USB. We’ll be using an Arduino for this. And here’s the steps we’ll need to take to connect it all.

  1. If you like, you can fasten the Arduino to the top of the headset using tape or zip ties.
  2. Connect the T pin wire from the headset to the RX pin on the Arduino.
  3. Connect the Ground wire from the headset to a Ground pin on the Arduino.
  4. Using a USB cable, connect the Arduino to your computer.
  5. Download and install the Arduino software version 1.0.5.
  6. The software doesn’t work with any newer versions.
  7. Before starting up the software, download and install the Arduino Brain library. You want to place it in your Arduino Libraries folder.
  8. Startup the software and load up the test program by going to File > Examples > Brain > BrainSerialTest
  9. Upload it to the Arduino (you may have to temporarily remove the RX wire in order to do this)
  10. Open up the serial console, put the headset on your head, turn it on, and see what results you get!
  11. The first number is the signal strength, the second is the attention value, and the third is the mediation value.

***PLEASE NOTE*** If you continuously get a 200,0,0 as your status, this may be due to a grounding issue with the headset. If you are using a laptop, unplug it and let it run off of battery while your headset is plugged in to see if it fixes the issue.

Step 5: Resetting the Arduino

Picture of Resetting the Arduino

Unfortunately, in its purchased state, the Arduino Uno R2 and R3 cannot emulate a keyboard and send keyboard commands to a computer. The Arduino Leonardo can do this, but it would be ideal if we did not have to purchase another Arduino just to simulate keystrokes. Luckily, this tutorial by Kevin DeMarco shows us a workaround that allows an Arduino Uno R3 and R2 to emulate a keyboard by resetting the Atmega chip.

If you are using Windows or Mac, you can follow the similar steps listed here.

Here are the steps for linux:

  1. Place the hard drive jumper on the reset and ground Arduino pins as shown in the image to the left.
  2. Power on the Arduino by plugging it into your computers USB port.
  3. Once you see the Arduino receive power, wait a few seconds and then remove the jumper from the pins. This should place the Arduino in reset mode, and we can now upload our own firmware.

Step 6: Uploading New Firmware

Picture of Uploading New Firmware

As mentioned in the previous step, with the Arduino in reset mode, we can upload our own firmware to the Atmega chip. Why would we want to do this? Because it will allow us to have the Arduino act as an HID keyboard. So here’s the steps to get started:

  1. Open up a linux terminal
  2. Update apt-get
    1. sudo apt-get update
  3. Install the DFU (Device Firmware Updater) Program
    1. sudo apt-get install dfu-programmer
  4. Download and unzip the custom firmware we will need for this project. This zip file contains two hex files: Arduino-keyboard-0.3.hex and Arduino-usbserial-uno.hex
    1. wget http://www.tinkernut.com/demos/arduino_hid/arduino_hid.zip
    2. unzip arduino_hid.zip
  5. Use the DFU programmer to erase the chip, upload a new firmware, and reset the chip. For this example, we will just upload an Atmega16u2 version of the USB firmware.
    1. sudo dfu-programmer atmega16u2 erase
    2. sudo dfu-programmer atmega16u2 flash --debug 1 Arduino-usbserial-uno.hex
    3. sudo dfu-programmer atmega16u2 reset

With the new firmware uploaded, you now have to power-cycle the Arduino. You can do this by simply unplugging it and plugging it back in.

Step 7: Emulating a Keyboard

Picture of Emulating a Keyboard

We now know how to flash the firmware, so now we need to make it act like a keyboard. So the first thing we need to do is write a simple program for the Arduino that sends keystrokes to the serial console. How we send a keystroke? By using this list of HID keyboard codes to find the character you want to send. Below is the sample code provided by Kevin DeMarco:

/* Arduino USB HID Keyboard Demo
* Random Key/Random Delay
*/
uint8_t buf[8] = {
0 }; /* Keyboard report buffer */

void setup()
{
Serial.begin(9600);
randomSeed(analogRead(0));
delay(200);
}

void loop()
{
delay(5000);

buf[0] = 0;
buf[2] = 0x15; // letter R
Serial.write(buf, 8);
releaseKey();
}

void releaseKey()
{
buf[0] = 0;
buf[2] = 0;
Serial.write(buf, 8); // Release key
}

Check this code for errors and then upload it to the Arduino. Now all that’s left to do is follow the same steps as in steps 2 and 3 to upload the Arduino Keyboard firmware. Briefly, here are the

  1. Unplug the Arduino from the computer
  2. Place the hard drive jumper on the Ground and Reset pins.
  3. Plug the Arduino back into the computer so that it powers on
  4. Remove the hard drive jumper
  5. In your computer terminal, execute these commands to upload the Arduino Keyboard firmware
    1. sudo dfu-programmer atmega16u2 erase
      sudo dfu-programmer atmega16u2 flash --debug 1 Arduino-keyboard-0.3.hex
      sudo dfu-programmer atmega16u2 reset
  6. Power cycle the Arduino by unplugging it and plugging it back in.

With your Arduino reconnected, open up a text editor, and you should see the letter “R” being typed (or whichever letter you chose). You’ve successfully emulated a keyboard with your Arduino!

Step 8: Connecting It to the EEG

Picture of Connecting It to the EEG

The last step is to connect our EEG headset to the Arduino and edit the Arduino code so that it sends a keyboard command everytime our Brain data reaches a specific value. We can do this by opening up our Arduino code from the Homemade Mind Control TV Remote tutorial and removing all the code references to the IR LED and commands and then replacing them with our new keyboard commands. The final code should look something similar to this:

#include <Brain.h>
Brain brain(Serial);
long interval = 500; 
long previousMillis = 0; 
int medValue;
uint8_t buf[8] = { 0 };
void setup() {
 Serial.begin(9600);
 randomSeed(analogRead(0));
 delay(200);
}
void loop() {
 if (brain.update()) {
 Serial.println(brain.readCSV());
 medValue = brain.readMeditation();
 }
 if(brain.readSignalQuality() == 0) {
 if (medValue < 50) {
 buf[0] = 0;
 buf[2] = 0x17; // letter T
 Serial.write(buf, 8);
 delay(40);
 releaseKey();
 
 buf[0] = 0;
 buf[2] = 0x0C; // letter I
 Serial.write(buf, 8);
 delay(40);
 releaseKey();
 
 buf[0] = 0;
 buf[2] = 0x11; // letter N
 Serial.write(buf, 8);
 delay(40);
 releaseKey();
 
 buf[0] = 0;
 buf[2] = 0x0E; // letter K
 Serial.write(buf, 8);
 delay(40);
 releaseKey();
 
 buf[0] = 0;
 buf[2] = 0x08; // letter E
 Serial.write(buf, 8);
 delay(40);
 releaseKey();
 
 buf[0] = 0;
 buf[2] = 0x15; // letter R
 Serial.write(buf, 8);
 delay(40);
 releaseKey();
 
 buf[0] = 0;
 buf[2] = 0x11; // letter N
 Serial.write(buf, 8);
 delay(40);
 releaseKey();
 
 buf[0] = 0;
 buf[2] = 0x18; // letter U
 Serial.write(buf, 8);
 delay(40);
 releaseKey();
 
 buf[0] = 0;
 buf[2] = 0x17; // letter T
 Serial.write(buf, 8);
 delay(40);
 releaseKey();
 
 buf[0] = 0;
 buf[2] = 0x28; // enter
 Serial.write(buf, 8);
 delay(40);
 releaseKey();
 }
 } 
 
}
void releaseKey()
{
buf[0] = 0;
buf[2] = 0;
Serial.write(buf, 8); // Release key
}

Before we can upload it to the Arduino, however, we need to convert the Arduino back into USB mode, so repeat Steps 2 and 3 for that.

And finally, once you have it uploaded to your Arduino, you will need to repeat step 4 to convert your Arduino back into keyboard mode.

If everything is successful, once you have your headset on and plugged into your computer, once your meditation value drops below 50, you should see your keyboard commands executed on the screen!

Comments

Stan1y (author)2015-04-26

If you made it emulate a usb mouse left /right, up/ down, left and right click it would need less code and be able to interface with almost any normal PC or mac soft ware

AyushP2 (author)Stan1y2017-02-05

it is actually possible to use the arduino uno to move a mouse WITHOUT using dfu and uploading a hex file. I did it by making some arduino code and java processing code and it worked, if you would like to know how, comment back,

karthik_geek14 (author)AyushP22017-02-05

AyushP2, It would be very helpful if you provide a tutorial on it as I want to do something similar on an Android device.

RishabhJ28 (author)2016-10-15

hi i am in need of desperate help i have the force trainer 2 headset it has a eeg board inside with the t pin to which i have soldered a jumper to rx on my arduino and also soldered a jumper from ground of the battery to ground of arduino, but when i upload the code with the rx pin removed then upload and reconnect switch on my headset, but no readings at all on the serial monitor

piplc1 (author)RishabhJ282016-12-31

Hi! you find a solution? I recieve weird letters only...

T0BY (author)2016-11-26

Blimey!

RamyP (author)2016-11-10

how to make a mind control jammer

SrinivasN8 (author)2016-10-02

I don't think its efficient.

StandardImagery (author)2016-08-16

Hi all,

this is my mind controlled arcade android game ..... https://www.youtube.com/watch?v=_ByxbzRYmpc

PJMOR (author)2016-07-21

I need to make myself one of these.

SinglePlayerPlus (author)2016-04-14

is there a way to do this with a raspberry pi? I have that but not an arduino

LauM4 (author)2016-02-07

Saludos desde Colombia.
Debo hacer como proyecto que una persona pueda encender y apagar un televisor, y esto me es de gran ayuda. La diaema (EEG) no la tengo, así que la idea es intentar con electrodos de superficie para captar las ondas cerebrales, utilizando Matlab. y luego hacer la conexión con arduino. Si tienes alguna idea que me facilite ese proceso, te agradecería.

WolfMaster333 (author)2015-12-13

Cool!

jjrlo (author)2015-09-02

Could you leave a link to the video
?

epitts2 (author)2015-05-17

How accurate can you make the keyboard function? Is it possible to combine this with other functions to be able to completely control your computer, as in all mouse functions and keyboard as well?

bombastinator (author)2015-04-28

Claiming you're controlling it "with your mind" is a cute magic trick, but that's not what you are actually doing. The problem is there are muscles all over the front of your head, and their electrical signals are orders of magnitude greater than those your brain makes. Any sensor placed over a muscle, even a tiny one will register only the movement of that muscle. ALL of your sensor points are over muscles.

What you are actually doing is small muscle biofeedback. Nothing wrong with that. It works. But it's not mind control any more than if you moved something with your arm. It just looks like it is.

gigafide (author)bombastinator2015-04-30

I did a lot of research into the Nerosky EEG devices (the chip manufacturer) before posting this, and you are partially correct, but saying that the chip ONLY reads muscle signals would be an incorrect statement. Neurosky chips can use muscle, eye, and eeg data to formulate more precise actions. Different units with the exact same chip output beta, theta, alpha, and gamma values that are comparable to medical EEG's. As far as this specific device (the device) is concerned, Neurosky has zero documentation on what it collects, so you may be correct, but knowing that the chip can collect more than just muscle movements, it's possible that you may not be correct. There's no real way to tell (given that the "patented" attention and mediation values it outputs are not comparable to any real world metrics). Here's some reference links:

http://frontiernerds.com/brain-hack

http://support.neurosky.com/kb/science/how-does-th...

http://neurosky.com/biosensors/eeg-sensor/

bombastinator (author)gigafide2015-05-01

Yes. If placed on a part of the head that did not have muscles on it, the thing would detect brain waves. The thing is, looking at the headset, that this is very specifically not being done. The sensors are instead placed directly over muscle groups which produce signals tens or hundreds of times stronger than a brainwave.

DennisF (author)bombastinator2015-04-28

I wonder if it really makes any difference when you consider how it's to be used. I think that if this device can be configured to emulate a keyboard, it could potentially emulate a pointing device or game controller. I'm thinking about how this could be mashed with a VR headset.

I'm not too crazy about this (yet) as I remember how it felt to be connected to a EKG. The glue works too well and removing the pads was painful when it ripped out the hair on my arms, chest and legs. Not very nice. I'd have to know more about the sensors before I'd be willing to put them on my head.

bombastinator (author)DennisF2015-04-28

only a very small one. If it's Biofeedback you can put the device anywhere, not just your head. This is actually an advantage when dealing with the disabled. Or, admittedly also the jokester who stuffs the thing down his trousers and manipulates the device with thigh muscles while making exaggerated pelvic thrusts as happened a few years ago when some toy manufacturer attempted to sell a foam ball/ air jet levitation game

DennisF (author)bombastinator2015-04-29

This made me curious so I found this video.

http://www.ted.com/talks/tan_le_a_headset_that_rea...

I'm not less concerned about the EEG pads although I wonder how well it will work for people with hair. Mine is still pretty thick but turning increasingly white. :)

Frank30509 (author)bombastinator2015-04-28

Oh chill out! It still super awesome! :D

bombastinator (author)Frank305092015-04-28

Oh I'm not saying it isn't. It's totally useful for, say quadriplegic patients and other stuff. I am making a nearly pure semantics point. I must point out the one non semantics item: "mind control" video controllers were marketed in the 70s and failed. This was because people felt the faces they had to make to use them were simply too embarrassing. This may apply here as well. Another ramification is that any part of the body can be used for small muscle biofeedback. You don't necessarily have to use your head.

masczone (author)bombastinator2015-04-28

You are incorrect. EEG leads are designed to pick up brainwaves. Even over muscles on the head. It is true however that muscle activity can interfere with signal. But brain waves have different signal.

For example. In my job we place people on EKG machine and it picks up a PQRS signal for the heart even if you are moving. These leads are not placed over the heart but on LA, RA, LL, RL.

bombastinator (author)masczone2015-04-28

not sure how your example supports your belief. Heart does not equal brain. As to EEG leads themselves, they're nothing but wires. A real EEG needs gold caps glued to the skull. Also when you get an EEG they very carefully DO NOT put any leads over muscles. This doesn't look like it's using either the caps or the locations used for EEG. I suppose it is not impossible that one could filter the signal from a lead to get around muscle signals.

There is an easy way to test this though: one of the famous symptoms of facial small muscle biofeedback is the "O" face. If when using the device the user has to make odd faces which happen to coincidently mimic those made in moments of passion (hence the name) it's probably small muse biofeedback. If you look at video of people using the original 1970s atari device (video on the net) you will have a good example.

zcheek (author)2015-04-28

I had no idea you had an Instructables account!! I've been following you on YouTube for a long time. Well, congreatulations on this build and also congradulations because you now have a stalker on both sites. LOL

gigafide (author)zcheek2015-04-30

Thanks zcheek! I do appreciate the stalkers :-)

AJMansfield (author)2015-04-29

You should probably reorder this - install programmer software first, then reset arduino firmware - just in case dfu-programmer doesn't install correctly.

ThomasL2 (author)2015-04-27

This is awesome! I'm beyond impressed. Question for you. The Star Wars Force Trainer is sold out at the store link provided. Looks like it's running for about $85 everywhere else. So I'm looking to purchase an EEG headset from Neurosky (The MindWave Mobile Starter Kit). Would the instructions to complete this project be the same or quite different/ more complex using the Neurosky unit? Thanks!

gigafide (author)ThomasL22015-04-28

Yes. The Neurosky headsets all use the same chip, and they have the added benefit of providing more data. The Force Trainer only provides 3 values (connection, attention, mediation), but the newer Neurosky headsets provide at least 6 different values. This tutorial will still work for connecting to those as well.

ThomasL2 (author)gigafide2015-04-29

That's great to know- thanks for confirming. I am ordering all my parts today- can't wait to get started. Will post my results when ready. :) Thanks again for sharing this- opened up a whole new door for me.

dick55 (author)ThomasL22015-04-28

Try this: https://learn.sparkfun.com/tutorials/hackers-in-residence---hacking-mindwave-mobile?_ga=1.62115368.586940628.1425103115

ThomasL2 (author)dick552015-04-29

Very helpful. Thanks buddy!

Alderin (author)2015-04-29

Very cool project! Not sure 'control a computer' quite fits, but one could definitely put a relay board to control the lights. Would be kinda cool if the lights dimmed when you were relaxed, but brightened when you were interested in something.

A pair of Moteinos from LowPowerLab ( http://lowpowerlab.com/ ) could eliminate the wires very easily. There is even a Moteino Leo that could be used for the keyboard emulation part.

A comment mentioned that muscle electrical output is much greater, which makes me wonder about instead sensing certain facial and jaw muscles for wearable animatronics or augmented vision (eg. zoom in by squinting). This measurement should be both easier to obtain and easier to master, as the muscles are at least partially consciously controlled...

Another project for the pile. :-)

perfo (author)2015-04-29

Sorry if this post appears elsewhere, I have already entered it but it seems to have disappeared.

Anyway thanks for the ible...lots of food for though there.

in your experience how many levels can you reliably and repeatedly reproduce ? Is it only practical to have a binary state out of this ?

Thanks.

DarkDecko (author)2015-04-28

Also I forgot to mention this... have you tried controlling the mouse and both the keyboard and mouse at the same time? If you can pull it off us poor NERDS that can't afford an EMOTIV device would be so greatful

DarkDecko (author)2015-04-28

I know you said you can turn the Adruino into a keyboard but can you replace the words with a voice synthesizer? If so it can be just like the movie UP when the dog could talk

BrianA5 (author)2015-04-28

Can you do this with a raspberry pi and python? Id like to add on to a old raspberry pick project with this :D

mr.frob (author)2015-04-28

I've seen this toy on that website and considered buying it for this very purpose, but I was skeptical on the validity of the site and whether I could trust them. I might have to give it a try now.

stephenmack (author)2015-04-28

Nice Instructable! Voted.

Zulubo (author)2015-04-28

Hahah! I actually have this toy already! Time to put it to good use...

jerbs (author)2015-04-28

I've created an EEG with my Mind Flex before (http://frontiernerds.com/brain-hack), I'm guessing this tutorial should work for the Mind Flex as well?

jiovine (author)2015-04-28

Hello,

I like your project. I'm wondering if it can be ported over to a PIC microcontroller. Do you know what the raw data signals are from the T pin wire? I go the idea it might be serial data output from this statement :

***PLEASE NOTE*** If you continuously get a 200,0,0 as your status,

Thanks,

John

gigafide (author)jiovine2015-04-28

Respectively the 200,0,0 is connection strength (200 is bad, 0 is good), attention, and meditation. Keep in mind that these don't necessarily represent beta, theta, alpha, or any other specific brain waves, but they do represent brain activity.

jiovine (author)gigafide2015-04-28

Yes thank you for that information. But do you know how the numbers are given off the T pin wire? Is it a serial output? If so do you know the baud rate and protocol?

Thanks,

John

jiovine (author)gigafide2015-04-28

Yes, thank you for that, but how are those numbers coming off the T pin wire? Is it serial data? If so, do you know the baud rate, and protocol?

perfo (author)2015-04-28

A nice ible thanks... it got me thinking (pun intended). How many different signals can you detect reliably. For example could I set something up with eight states and reliably pick one of those states using this set up ?
Like a remote control car for example if you have speed +- turn left right ie just digital states but you would need them to be repeatable and reliable?

I would also be trying to do it with a raspberry pi, mainly as I have a few of them..

Thanks

Everything impossible (author)2015-04-28

I wish they just sold these!

GregQ (author)2015-04-28

...they make u lift up big rocks with the power of your brain

they'll make u face ur destiny and your never be the same
and your head will cause you pain... --Weird Al "Livin' the Vida Yoda"

Just4Fun Media (author)2015-04-26

Great instructable! Very deserving of my vote.

Quick question, how accurate is your control? As in do you receive a lot of interference,etc.

About This Instructable

84,433views

904favorites

License:

More by gigafide:Youtube Live Streaming CameraDIY Vintage Streaming Radio With a Raspberry PiTurn an Old Cell Phone Into a Smartwatch
Add instructable to: