Control a Computer With Your Mind!

87,823

913

72

Published

Introduction: 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

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

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

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

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

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

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

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!

Coded Creations

Second Prize in the
Coded Creations

Share

Recommendations

  • Oil Contest

    Oil Contest
  • Creative Misuse Contest

    Creative Misuse Contest
  • Water Contest

    Water Contest

72 Discussions

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

2 replies

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,

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

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

1 reply

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

0
user
T0BY

1 year ago

Blimey!

0
user
RamyP

1 year ago

how to make a mind control jammer

I don't think its efficient.

Hi all,

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

0
user
PJMOR

1 year ago

I need to make myself one of these.

0
user
LauM4

2 years ago

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.

0
user
jjrlo

2 years ago

Could you leave a link to the video
?

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?

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.

4 replies

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/

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.

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.

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