Introduction: Blink LED Using Your Brainwaves

Picture of Blink LED Using Your Brainwaves

What is Brainsense Headband ?

Brainsense is, a sleek, single-channel, wireless headset that monitors your brain activity and translates EEG into meaningful data you can understand .The biosensor platform provides a powerful foundation for the development of a variety of applications that promote Mind health such as improved focus, concentration, working memory and acuity. Other uses include meditation and relaxation monitoring or improved educational processes. Our low cost, complete OEM solution is a high-performance bio-signal on a single chip solution for accurate Mind activity detection and processing. Brainsenseuses neurosky TGAM1 Module.

Materials Required

Hardware’s:

1. Brainsense Headband

2. Arduino Board

3. HC-05 Bluetooth Module

4. USB cable (for Arduino)

5. Connecting Wires.

Software’s:

1. Flash magic ,X-CTU (any serial communication software)

2. Arduino 1.0.5-r2

Step 1: Configration of Bluetooth Module

Picture of Configration of Bluetooth Module

Bluetooth Module (HC-05)

It’s a high performance Bluetooth module HC-05. This is a standalone BTM-05 Bluetooth module. Its works as TTL Master/Slave Transceiver module with serial UART protocol for communication. Designed by Full speed Bluetooth operation with full piconet support. It allows you to achieve the industry’s highest levels of sensitivity, accuracy, with lowest power consumption.

Configuration of HC-05:

·Its configure as master mode

·Brainsense Headband act as slave device

Step 2: Add Device in Control Panel

Picture of Add Device in Control Panel

1. Select your Brainsense Headband in the control panel in the add device wizard

Step 3: Find the Unique Identiifer Number

Picture of Find the Unique Identiifer Number

Find the unique Identiifer number as shown in the figure

Example:
The brainsense Unique no in the figure is 98d3,31,302424

Step 4: Configure HC-05 Bluetooth Module With Brainsense

Picture of Configure HC-05 Bluetooth Module With Brainsense

Note: Here the Arduino Board is used only for USB to UART converter. So no need to sketch the board.

Step 5: Steps to Configure HC-05 in Command Mode

Picture of Steps to Configure HC-05 in Command Mode

Pressand Hold the Push switch in HC-05 module at few secs, when its power ON (In between OFF state to ON state).

If HC-05 Module in Command mode , the LED blink at less rates (blinking slowly).

Baud rate for Command Mode

In command mode the HC-05 module works at fixed baud rate (38400 Baud).

In default state, the HC-05 module works as a Data mode operation.

If HC-05 Module in Data mode means, the LED blink at fast rates(Blinking fast)

Baud rate for Data Mode

In Data mode the HC-05 module works in variable Baud rate.

AT Commands for HC-05 to pair with Brainsense

First configure HC-05 into command mode, then enter the following AT commands for HC-05 module to communicate our BrainsenseHeadband.

1. AT+NAME=”PANTECH”

2. AT+UART=”57600,0,0”

3. AT+ROLE=”1”

4. AT+PSWD=”0000”

5. AT+CMODE=”0”

6. AT+BIND=”XXXX,YY,ZZZZZZ”(Brainsense Unique Number)

7. AT+IAC=”9E8B33”

8. AT+CLASS=”0”

9. AT+INQM=”1,9,48”

Step 6: Verification Commands for HC-05 Module

Picture of Verification Commands for HC-05 Module

Verification commands for HC-05 Module

1. AT

OK

2. AT+UART?

+UART:57600,0,0

OK

3. AT+ROLE?

+ROLE:1

OK

4. AT+PSWD?

+PSWD:0000

OK

5. AT+CMODE?

+CMODE:0

OK

6. AT+BIND?

+BIND:9cb7:0d:89e51c

OK

7. AT+IAC?

+IAC:9E8B33

OK

8. AT+INQM?

+INQM:1,9,48

OK

Step 7: Interfacing Arduino With Brainsense Headband

Picture of Interfacing Arduino With Brainsense Headband

Steps to follow

1. Program (Upload the sketch) the “Brainsensewith Arduino” source code to Arduino Board using Arduino compiler.

2. Open the “Serial Monitor” in Arduino compiler with 57600 baud rate.

3. Make all the connection as per the above image, and then switch ON the Arduino Board.

4. After the few Seconds, switch ON the BrainsenseHeadband.

5. Now the BrainsenseHeadband and Arduino Board will pair automatically.

6. Wear the BrainsenseHeadband in your Head, and give the attention.

7. Check the LED variation with respect your attention level.

8. And also see the Serial Monitor to know your Poor quality and attention levels.

Step 8: Upload the Sketch to Arduino Board

Picture of Upload the Sketch to Arduino Board

Download the sketch here

Program for Interfacing Arduino with BrainsenseHeadband

***************************************************************************************

Title: Brainsense with Arduino

***************************************************************************************

///////////////////////////////////////////////////////////////////////

/ Arduino Bluetooth Interface with Brainsense

//

// This is example code provided by Pantech Prolabs. and is provided

// license free.

////////////////////////////////////////////////////////////////////////

#define LED 13

#define BAUDRATE 57600

#define DEBUGOUTPUT 0

#define GREENLED1 3

#define GREENLED2 4

#define GREENLED3 5

#define YELLOWLED1 6

#define YELLOWLED2 7

#define YELLOWLED3 8

#define YELLOWLED4 9

#define REDLED1 10

#define REDLED2 11

#define REDLED3 12

#define powercontrol 10

// checksum variables

byte generatedChecksum = 0;

byte checksum = 0;

int payloadLength = 0;

byte payloadData[64] = {0};

byte poorQuality = 0;

byte attention = 0;

byte meditation = 0;

// system variables

long lastReceivedPacket = 0;

boolean bigPacket = false;

/////////////////////////

/ Microprocessor Setup /

/////////////////////////

void setup()

{

pinMode(GREENLED1, OUTPUT);

pinMode(GREENLED2, OUTPUT);

pinMode(GREENLED3, OUTPUT);

pinMode(YELLOWLED1, OUTPUT);

pinMode(YELLOWLED2, OUTPUT);

pinMode(YELLOWLED3, OUTPUT);

pinMode(YELLOWLED4, OUTPUT);

pinMode(REDLED1, OUTPUT);

pinMode(REDLED2, OUTPUT);

pinMode(REDLED3, OUTPUT);

pinMode(LED, OUTPUT);

Serial.begin(BAUDRATE); // USB

}

///////////////////////////////

/ Read data from Serial UART /

///////////////////////////////

byte ReadOneByte()

{

int ByteRead;

while(!Serial.available());

ByteRead = Serial.read();

#if DEBUGOUTPUT

Serial.print((char)ByteRead); // echo the same byte out the USB serial (for debug purposes)

#endif

return ByteRead;

}

////////////

/MAIN LOOP/

////////////

void loop()

{

// Look for sync bytes

if(ReadOneByte() == 170)

{

if(ReadOneByte() == 170)

{

payloadLength = ReadOneByte();

if(payloadLength > 169) //Payload length can not be greater than 169

return;

generatedChecksum = 0;

for(int i = 0; i < payloadLength; i++)

{

payloadData[i] = ReadOneByte(); //Read payload into memory

generatedChecksum += payloadData[i];

}

checksum = ReadOneByte(); //Read checksum byte from stream

generatedChecksum = 255 - generatedChecksum; //Take one's compliment of generated checksum

if(checksum == generatedChecksum)

{

poorQuality = 200;

attention = 0;

meditation = 0;

for(int i = 0; i < payloadLength; i++)

{ // Parse the payload

switch (payloadData[i])

{

case 2:

i++;

poorQuality = payloadData[i];

bigPacket = true;

break;

case 4:

i++;

attention = payloadData[i];

break;

case 5:

i++;

meditation = payloadData[i];

break;

case 0x80:

i = i + 3;

break;

case 0x83:

i = i + 25;

break;

default:

break;

} // switch

} // for loop

#if !DEBUGOUTPUT

// *** Add your code here ***

if(bigPacket)

{

if(poorQuality == 0)

digitalWrite(LED, HIGH);

else

digitalWrite(LED, LOW);

Serial.print("PoorQuality: ");

Serial.print(poorQuality, DEC);

Serial.print(" Attention: ");

Serial.print(attention, DEC);

Serial.print(" Time since last packet: ");

Serial.print(millis() - lastReceivedPacket, DEC);

lastReceivedPacket = millis();

Serial.print("\n");

switch(attention / 10)

{

case 0:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, LOW);

digitalWrite(GREENLED3, LOW);

digitalWrite(YELLOWLED1, LOW);

digitalWrite(YELLOWLED2, LOW);

digitalWrite(YELLOWLED3, LOW);

digitalWrite(YELLOWLED4, LOW);

digitalWrite(REDLED1, LOW);

digitalWrite(REDLED2, LOW);

digitalWrite(REDLED3, LOW);

break;

case 1:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, LOW);

digitalWrite(YELLOWLED1, LOW);

digitalWrite(YELLOWLED2, LOW);

digitalWrite(YELLOWLED3, LOW);

digitalWrite(YELLOWLED4, LOW);

digitalWrite(REDLED1, LOW);

digitalWrite(REDLED2, LOW);

digitalWrite(REDLED3, LOW);

break;

case 2:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, LOW);

digitalWrite(YELLOWLED2, LOW);

digitalWrite(YELLOWLED3, LOW);

digitalWrite(YELLOWLED4, LOW);

digitalWrite(REDLED1, LOW);

digitalWrite(REDLED2, LOW);

digitalWrite(REDLED3, LOW);

break;

case 3:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, HIGH);

digitalWrite(YELLOWLED2, LOW);

digitalWrite(YELLOWLED3, LOW);

digitalWrite(YELLOWLED4, LOW);

digitalWrite(REDLED1, LOW);

digitalWrite(REDLED2, LOW);

digitalWrite(REDLED3, LOW);

break;

case 4:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, HIGH);

digitalWrite(YELLOWLED2, HIGH);

digitalWrite(YELLOWLED3, LOW);

digitalWrite(YELLOWLED4, LOW);

digitalWrite(REDLED1, LOW);

digitalWrite(REDLED2, LOW);

digitalWrite(REDLED3, LOW);

break;

case 5:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, HIGH);

digitalWrite(YELLOWLED2, HIGH);

digitalWrite(YELLOWLED3, HIGH);

digitalWrite(YELLOWLED4, LOW);

digitalWrite(REDLED1, LOW);

digitalWrite(REDLED2, LOW);

digitalWrite(REDLED3, LOW);

break;

case 6:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, HIGH);

digitalWrite(YELLOWLED2, HIGH);

digitalWrite(YELLOWLED3, HIGH);

digitalWrite(YELLOWLED4, HIGH);

digitalWrite(REDLED1, LOW);

digitalWrite(REDLED2, LOW);

digitalWrite(REDLED3, LOW);

break;

case 7:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, HIGH);

digitalWrite(YELLOWLED2, HIGH);

digitalWrite(YELLOWLED3, HIGH);

digitalWrite(YELLOWLED4, HIGH);

digitalWrite(REDLED1, HIGH);

digitalWrite(REDLED2, LOW);

digitalWrite(REDLED3, LOW);

break;

case 8:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, HIGH);

digitalWrite(YELLOWLED2, HIGH);

digitalWrite(YELLOWLED3, HIGH);

digitalWrite(YELLOWLED4, HIGH);

digitalWrite(REDLED1, HIGH);

digitalWrite(REDLED2, HIGH);

digitalWrite(REDLED3, LOW);

break;

case 9:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, HIGH);

digitalWrite(YELLOWLED2, HIGH);

digitalWrite(YELLOWLED3, HIGH);

digitalWrite(YELLOWLED4, HIGH);

digitalWrite(REDLED1, HIGH);

digitalWrite(REDLED2, HIGH);

digitalWrite(REDLED3, HIGH);

break;

case 10:

digitalWrite(GREENLED1, HIGH);

digitalWrite(GREENLED2, HIGH);

digitalWrite(GREENLED3, HIGH);

digitalWrite(YELLOWLED1, HIGH);

digitalWrite(YELLOWLED2, HIGH);

digitalWrite(YELLOWLED3, HIGH);

digitalWrite(YELLOWLED4, HIGH);

digitalWrite(REDLED1, HIGH);

digitalWrite(REDLED2, HIGH);

digitalWrite(REDLED3, HIGH);

break;

}

}

#endif

bigPacket = false;

}

else {

// Checksum Error

} // end if else for checksum

} // end if read 0xAA byte

} // end if read 0xAA byte

}

Step 9: LED Bliking on Arduino

Picture of LED Bliking on Arduino

Step 10: Output on Serial Monitor

Picture of Output on Serial Monitor

You could use the same code to interface Neurosky Mindwave mobile with arduino

Comments

JavaProgrammer (author)2015-03-10

how much does the brainsense cost in US Dollars? I tried the website but all it says is "Rs 6,999.00"

MrE (author)JavaProgrammer2015-03-14

All you have to do to translate any money is google it and add to dollars and it auto calculates for you. By the it comes out to $110.00 dollars. Just an fyi for you.

currently it is available only in india,you could use neurosky mindwave mobile alternatively,the same tutorial will work for that.

tkalkavan made it! (author)2015-10-13

Be careful about pwd="0000" and Hc-05 Tx goes to Arduino Rx.

manishunny (author)tkalkavan2017-08-16

i will connect all these things same as to be shown , but i unable to connect my mindwave headset to hc-05 module i will nothing to see in serial monitor, please help me !

nanwaar (author)2017-04-22

hi i hope you will be fine, i wanted to get neurosky eeg headset band values like alpha,beta,gamma,delta and theta. i need help how to get those on arduino via bluetooth

RishabhG43 (author)2017-01-14

@JeevarajanM Can we recharge the brainsense,is there any way to interface brainsense with MATLAB, or any user guide,please help me

JeevarajanM (author)RishabhG432017-01-14

currently there is no rechargeable batteries,it needs 3 aaa batteries,for six hours of continuous operation.pls find the link to interface with matlab
https://www.pantechsolutions.net/brain-computer-interface

AungM12 (author)2016-06-09

are there low cost brainsense that can also blink LED using your brainwaves?

RS 6999 , that thing is expensive? Are there any other stuff?

MaheshP46 (author)2016-03-24

Sir is it possible to control 3 devices like ON/OFF with this head band

tkalkavan made it! (author)2015-10-13

Great tutorial!. Be careful about pwd="0000" and Hc-05 Tx goes to Arduino Rx.

Godzilla54 (author)2015-03-23

MIND BLOWED wait I cant use this if my mind blew up.

Electronics Circuits (author)2015-03-12

Never occurred to me this could be possible. Amazing!

tomatoskins (author)2015-03-10

This is great! Thanks for sharing your code!

About This Instructable

12,219views

121favorites

License:

More by JeevarajanM:Getsure Control Robot carBlink LED using your Brainwaves
Add instructable to: