Electronics


Got Questions?

Submit Them Here!

ASK A QUESTION

Step 1

Gather The Parts

01_gather_parts

If you want to follow along with this project here’s a list of parts you will probably need to order. The more parts that you already have, the cheaper this project will be.

  • Star Wars Force Trainer= $40
  • Arduino = $7
  • IR Receiver/IR LED = $0 (scavenged from old VCR)
  • 100k ohm resistor/various wires = $0 (already had/scavenged)

Step 2

Disassemble the Force Trainer

05_step2


06_step2


04_step3

07_step2

08_step2


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.

  • On the headset, remove the batteries and the screws that hold the top plate on.
  • Locate the Neurosky EEG board, as pointed out on the left.
  • Solder a wire to the T-Pin on the EEG board.
  • Solder a second wire to the Ground terminal on the battery case.
  • Drill or carve a small hole in the plastic casing that the wires can run through.
  • 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 3

Connecting the Arduino

09_step3

10_step3

03_step3


11_step3


12_step3

 
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.

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

Step 4

Creating the IR Remote

Screen Shot 2015-02-22 at 9.47.54 PM



13_step4

14_step4

15_step4

So we have the headset connected to the computer, and we are now viewing and collecting our brain wave data, but now what do we do with it? One solution is to connect an LED to the ground and 13 pins on the Arduino and to upload the BrainBlinker example program to the Arduino. But the solution we’re choosing for this tutorial is creating an IR remote. In order to do that, however, we first need to mimic a remote. Here’s the steps you’ll need to take in order to do that.

  • In order to test this out, you may want to remove the headset wires from the Arduino for the time being.
  • The first thing you need to do is acquire an IR receiver and an IR LED. You can purchase them, or you can usually salvage them from old electronics (such as VCR’s).
  • Connect the IR Receiver Ground pin to a Ground pin on the Arduino, the power pin to the 5v pin, and the data pin to pin 11.
  • Connect the IR LED Ground pin to a Ground pin on the Arduino, and the power pin to a 100 ohm resistor and then to pin 3 on the Arduino.
  • Then connect the Arduino to the computer.
  • Before starting up the Arduino software, download the Arduino IR Library software and install it in your Arduino Libraries folder.
  • After loading up the Arduino software, paste in the following program:
#include <IRremote.h>

const int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  irrecv.blink13(true);
}

void loop() {
  if (irrecv.decode(&results)) {
    if (results.decode_type == NEC) {
      Serial.print("NEC: ");
    } else if (results.decode_type == SONY) {
      Serial.print("SONY: ");
    } else if (results.decode_type == RC5) {
      Serial.print("RC5: ");
    } else if (results.decode_type == RC6) {
      Serial.print("RC6: ");
    } else if (results.decode_type == UNKNOWN) {
      Serial.print("UNKNOWN: ");
    }
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
}

Once this program is uploaded to your Arduino, open up the serial monitor, point a remote at the IR receiver and start pressing buttons. You should see a response in the results in the serial monitor screen. This will be the button code. You want to write down this code for later use (ex: NEC: 10EF22DD)

After you have the button code or codes that you want to use, we now need to see if we can send those codes to the IR led and see if they work.

  • In the Arduino software, load the File > Examples > IRremote > IRsendDemo program.
  • Replace the “irsend” command with the code from the button you want to emulate.
    • Example: irsend.sendNEC(0x10EFA05F, 32);
  • Upload this new program to the Arduino and place it next to the object you want to control.
  • In the Arduino software, open up the serial monitor, type in some text and click “send”.
  • If all goes well, a signal should be sent through the LED and should be received by the object you want to control.

Step 5

Controlling the Remote With Your Mind

16_step5

17_step5

We have our mind control, and we have our remote, so now let’s combine the two. It’s actually fairly simple. The toughest part is coming up with the code to control it. Here’s the steps.

  • Remove the IR receiver from the Arduino.
  • Leave the IR LED as is.
  • Reconnect the T Pin wire from the headset to the RX port on the Arduino.
  • Connect the ground wire to the IR LED ground.
  • Plug the Arduino into your computer and load in this code (replacing the button code with your own)
#include <IRremote.h>
#include <IRremoteInt.h>
#include <Brain.h>
IRsend irsend;
Brain brain(Serial);
const int ledPin = 3; 
long interval = 500; 
long previousMillis = 0;
int ledState = LOW; 
int medValue;
void setup() {
 // Set up the LED pin.
 pinMode(ledPin, OUTPUT);
 
 // Start the hardware serial.
 Serial.begin(9600);
}
void loop() {
 // Expect packets about once per second.
 if (brain.update()) {
 Serial.println(brain.readCSV());
 
 // Attention runs from 0 to 100.
 medValue = brain.readMeditation();
 }
 
 // Make sure we have a signal.
 if(brain.readSignalQuality() == 0) {
 
 // Send a signal to the LED.
 if (medValue < 50) {
irsend.sendNEC(0x10EFA05F, 32); 
 delay(40);
 }
 } 
 
}

Now you can open up the Arduino serial console and monitor your brain waves. Once the meditation value dips below 50, a signal should be sent to the IR LED with your command! Feel free to edit this code to make it control what you want!