Abstract

An EEG will read and process brain signals. The data would be interpreted into movement commands that are sent to an Arduino on a Halbot.

Hardware

Brain waves are read by a Mindwave electroencephalogram(EEG) through a single electrode on the forehead and one electrode on each earlobe. The electrode on the forehead reads electrical impulses that are filtered by the peripheral electrodes to reduce noise. The EEG is connected to an arduino by soldering the T pin and ground on the EEG and linking that to the arduino. Bluetooth modules are used to send data from one arduino to another arduino on a Halbot. Both the Halbot and the EEG can run on a battery pack, but it is also possible to connect the EEG with a computer to graph the signal.

List of hardware: Mindflex EEG; (2x) Arduino Uno; Bluetooth Modules (Master and Slave); Halbot - 2 DC Motors and 2 Omnidirectional Wheels and polycarbonate base;

Software

The project runs on arduino with the Brain library to interpret the signal from the EEG. Most of the signal processing is done on an embedded PCB on the EEG. The arduino brain library provides values for Attention, Meditation, Delta, Theta, Low Alpha, High Alpha, Low Beta, High Beta, Low Gamma, and Mid Gamma. The values provide the relative amount of each type of wave, but we chose to primarily analyze the meditation values from the EEG.

Visualizing the Data, Link for Brain Library:
http://www.frontiernerds.com/brain-hack

Configuring Bluetooth: https://create.arduino.cc/projecthub/user206876468/arduino-bluetooth-basic-tutorial-d8b737

Code

SLAVE

#include <SoftwareSerial.h>
SoftwareSerial  BTSerial(2, 3); //TX RX
int motorPin_Left = 6; // Motor connected to digital pin 3
int motorPin_Right = 5;//Motor to pin 5 
int incomingByte = 0;

void setup() {
  BTSerial.begin(9600); //begin bluetooth communication
  Serial.begin(9600); //begin serial communication
  incomingByte= 100;
}

void loop() {
  if (BTSerial.available()) {
    incomingByte =  BTSerial.read(); //reads single character at a time

    //Forward 
    if(incomingByte == 87){
      analogWrite(motorPin_Left, 200);
      analogWrite(motorPin_Right, 200);
    }
    //Left
    if(incomingByte == 65){
      analogWrite(motorPin_Left, 0);
      analogWrite(motorPin_Right, 200);
    }
    //Right 
    if(incomingByte == 68){
     analogWrite(motorPin_Left, 200);
     analogWrite(motorPin_Right, 0);
    }

    //Stop 
    if(incomingByte == 83){
      analogWrite(motorPin_Left, 0);
      analogWrite(motorPin_Right, 0);
    }
    Serial.println(incomingByte, DEC);
  }
}

MASTER

#include <SoftwareSerial.h>
#include <Brain.h>
SoftwareSerial  BTSerial(2, 3); //TX RX
Brain brain(Serial);
int attValue =0;
int incomingByte = 0;
void setup() {
  BTSerial.begin(9600); 
  Serial.begin(9600);
}

void loop() {
//incomingByte = 100;  
 if (brain.update()) {
 Serial.println(brain.readCSV());

 // Attention runs from 0 to 100.
 attValue = brain.readMeditation();

  if(brain.readSignalQuality() == 0) {
    if( attValue < 30) {
      BTSerial.print("S");
    }
    if( attValue < 50 && attValue >= 30) {
       BTSerial.print("W");
    }
    if(attValue < 70 && attValue >= 50) {
      BTSerial.print("D");
    }
    if( attValue >= 70) {
      BTSerial.print("A");
    }
  }
  else {
     BTSerial.print("S");
  } 
 }   
}

Built With

Share this project:

Updates