It is very clear that EEG sensors and headsets are becoming more commercialized and thus accessible to users for building custom brain-machine interfaces with various functionalities from switching TV channels to controlling wheelchairs as in this case. We decided to take it one step further. Here we will show you how we created a Mind-Controlled Robot using Arduino which was later converted to a wheelchair.
About our Sponsor
This Project is Sponsored by WIN SOURCE. WIN SOURCE is a leading electronic components supplier from China. Its online electronic component store contains a wide range of commonly used materials at very good prices, various obsolete and alternative parts also can
be found here.
NeuroSky produces and supplies an IC that can provide filtered, raw EEG data from electrodes connected to our head. But they also produce awesome hardware equipment for toys such as MindFlex (a game in which a ball is mind-controlled using focus and relaxation level of our mind). For us, this was a cheaper option to get the EEG data for our project. It could give us everything, neat and filtered for less than half the cost.
We later confirmed that, with proper and careful modifications to the internal circuit, the MindFlex headset will function normally at the same time, we could sniff out the data which is transmitted from the headset to the gaming console.
We could hack into it, tap the communication lines, connect it to the arduino, process it, drive the motors and make a Mind Controlled Robot using Arduino.
Demo Video
Mind Controlled Robot using Arduino – Tutorial
Components Required
Hardware list:
• Mind Flex
• AAA batteries for the headset
• Arduino
• Some hookup wire.
• A PC
• L293D Motor Driver IC
• DC Motor Driver Board
• DC Motor Power Supply
Software list:
• Arduino Brain Library
• Processing Brain Visualizer
• Processing GUI
MindFlex
Mindflex is actually a game from Mattel which uses our brain frequency to move a ball through obstacles. The brain waves (EEG Signals) are captured using electrodes that are placed in the headband and these waves are processed to get the attention and meditation level, which is later fed to the base station via Bluetooth and uses it to control the fans and the movement of the ball.
We could modify the circuit in such a way that instead of transmitting the raw signals into the base station, we grabbed the signal directly form Neurosky EEG Chip, before being transmitted using an arduino micro controller leaving a schematic that looks more like this
We could process these raw signals using an Arduino library and extract the value of meditation and attention from the signals. These signals are then used for moving the robot/wheelchair.
Click here to know how we modified Mindflex gaming headset to extract what we needed.
About the Raw Data
Depending up on our thoughts and state of our mind, the frequencies of our brain waves varies. Below are the classification of brain waves based on their frequencies.
• Delta (1-3Hz): sleep
• Theta (4-7Hz): relaxed, meditative
• Low Alpha (8-9Hz): eyes closed, relaxed
• High Alpha (10-12Hz)
• Low Beta (13-17Hz): alert, focused
• High Beta (18-30Hz)
• Low Gamma (31-40Hz): multi-sensory processing
• High Gamma (41-50Hz)
This Neurosky chipset outputs eight values depending up on the amount of electrical activity at different frequencies.Based on these values, neurosky calculates and outputs the value of “Attention” and “Meditation” which will be used to control the ball in the game.
• Attention level denotes the intensity of the players mental focus. Focusing on something or doing mental calculations can increase the concentration level and lack of concentration like wandering thoughts can decrease the attention level.
• Meditation denotes player’s mental calmness.
It is found that the degree of mental control over the signal varies from person to person. We will be using these values to control our robot/wheelchair.
Eye Blink switch
This Eye Blink sensor is IR based. Since the sensor works by looking for reflected light, it is possible to have a sensor that can return the value of the reflected light. This type of sensor can then be used to measure how “bright” the object is. This is useful for tasks like line tracking. The variation of brightness across the eye will vary as per eye blink. If the eye is closed means the output is high otherwise output is low. This to know the eye is in a closing or opening position. This output is given to the microcontroller.
TCRT5000 sensor consist of an IR diode that constantly fires IR rays and and the output stays low until the power of the reflected IR wave is above the threshold value.
Here, the infrared sensor is used to switch between straight movements and sidewise movements. It is fixed in a spectacle and it is placed in front if eye. The blinking of eye for a particular time is detected by the infrared sensor and hence the switching action is done. The output of the infrared sensor is given to Arduino microcontroller along with EEG input signals for further processing.
Below is the Circuit Diagram and PCB layout of the control Board
The Algorithm
The values of Attention and Meditation signals can be adjusted by the patient after some practice. The attention and meditation signals can be divided into three regions as shown. The variation will be fuzzy and will vary with each patient.
According to a patient’s response, the levels of these signals can be adjusted and can be used to control the wheelchair according to the following algorithm. Either attention or meditation signal value is taken. This value is used to control the wheel chair to move the chair forward, backward, right or left. The switching between straight movements and sidewise movements can be done using an infrared switch.
The digital values of attention and meditation signal can be obtained from the Neurosky EEG chip and these values can be processed using Arduino microcontroller.
The algorithm for processing is shown in the figure.
The Robot/Wheel Chair
Now lets get down to the moving part of Mind Controlled Robot using Arduino. Two wheels of the wheel chair are connected to the L293D motor driver. The L293D Dual H-Bridge Motor Driver Board is a great value and can be used with a variety of robot controllers. It features a powerful L293D motor driver module with a heavy duty heat sink. It is powerful enough to drive motors from 5-35 V at up to 2 A peak. This post explain everything about H Bridge and L293D and helps you get started with wheeled robots.
Below is the Circuit Diagram and PCB layout of L293D Motor Driver Circuit
Follow the steps below to configure the motor controller board to work as a typical robot motor driver for use with two DC motors.
- Attach your robot’s motors to the green Motor A and Motor B screw terminals.
- Connect the ENA and ENB to PWM capable digital outputs on your robot’s microcontroller.
- Connect the IN1, 2, 3 and 4 pins to any digital outputs of your robot’s microcontroller.
- Apply 5-16V to the board by connecting positive (+) to the blue VMS screw terminal and ground (-) to the blue GND screw terminal.
- See here for details on controlling the motors with your robot’s microcontroller.
Truth Table
Motor A truth table | |||
ENA | IN1 | IN2 | Description |
0 | N/A | N/A | Motor A is off |
1 | 0 | 0 | Motor A is stopped (brakes) |
1 | 0 | 1 | Motor A is on and turning backwards |
1 | 1 | 0 | Motor A is on and turning forwards |
1 | 1 | 1 | Motor A is stopped (brakes) |
Motor B truth table | |||
ENB | IN3 | IN4 | Description |
0 | N/A | N/A | Motor B is off |
1 | 0 | 0 | Motor B is stopped (brakes) |
1 | 0 | 1 | Motor B is on and turning backwards |
1 | 1 | 0 | Motor B is on and turning forwards |
1 | 1 | 1 | Motor B is stopped (brakes) |
The Code
#include <Brain.h> Brain brain(Serial); float at, med,st; int sw1,sw2,sw3,sw4,v1,v2,v3,v4,a,eo,ec,eca,eoa,et,eye; void setup() { Serial.begin(9600); pinMode(A0, INPUT); pinMode(A1, INPUT); pinMode(A2, INPUT); pinMode(A3, INPUT); pinMode(A4, INPUT); pinMode(A5, INPUT); pinmode(3, INPUT); pinMode(7, OUTPUT); pinMode(5, OUTPUT); pinMode(10, OUTPUT); pinMode(13, OUTPUT);
} |
void loop() { switching(); if((sw1==1)) { Serial.println("ON"); if((sw4==0)) { stp(); Serial.println("Stop"); } else if((sw4==1)) { if(at>80) { Serial.println("Forward"); Fwd(); else if(at<20) { Serial.println("Backward"); Bwd(); } else { Stp(); } } else if((sw4==2)) { stp(); Serial.println("Stop"); } else if((sw4==3)) {if(at>80) { Serial.println("Left"); Lft(); } else if(at<20) { Serial.println("Right"); Rit(); } Else { Stp(); } } else if((sw4==4)) { stp(); Serial.println("Stop"); } else if((sw1==0)) { Serial.println("OFF"); eyecal(); } } void switching() { int a; v1=analogRead(A4); v2=analogRead(A1); v3=analogRead(A2); v4=analogRead(A3); Serial.println("Switch 1: "); Serial.println(sw1); Serial.println("Switch 2: "); Serial.println(sw2); Serial.println("Switch 3: "); Serial.println(sw3); Serial.println("Switch 4: "); Serial.println(sw4); Serial.println(" "); if((v1>=550)) { sw1=sw1++; delay(100); } if((sw1==3)) { sw1=0; } if((v2>=550)) { sw2=sw2++; delay(100); } if((sw2==5)) { sw2=1; } //Switch3 if((v3>=550)) { sw3=sw3++; delay(100); } if((sw3==3)) { sw3=0; } //Switch4 if((eye<=et)) { delay(500); sw4=sw4++; } if((v4>=550)) { sw4=sw4++; delay(100); } if((sw4==8)) { sw4=0; } else { sw1=sw1; sw2=sw2; sw3=sw3; sw4=sw4; } } voideyecal() { eye=analogRead(A0); if((sw3==1)) { Serial.println("Open Your Eyes and Press Again"); eo=eye; } else if((sw3==2)) { Serial.println("Close Your Eyes and PressAgain"); ec=eye; } else if((sw3==0)) { et=(ec+eo)/2; Serial.println("Threshold = "); Serial.println(et); Serial.println("Analog Value = "); Serial.println(eye); } } void fwd() { digitalWrite(7, HIGH); digitalWrite(5, LOW); digitalWrite(10, HIGH); digitalWrite(13, LOW); analogWrite(9, 255); analogWrite(10, 255);} voidbwd() { digitalWrite(7, HIGH); digitalWrite(5, LOW); digitalWrite(10, HIGH); digitalWrite(13, LOW); analogWrite(9, 255); analogWrite(10, 255); } voidstp() { digitalWrite(7, LOW); digitalWrite(5, LOW); digitalWrite(10, LOW); digitalWrite(13, LOW); analogWrite(9, 255); analogWrite(10, 255); } voidlft() { digitalWrite(7, HIGH); digitalWrite(5, LOW); digitalWrite(10, LOW); digitalWrite(13, HIGH); analogWrite(9, 255); analogWrite(10, 255);} voidrit() { digitalWrite(7, LOW); digitalWrite(5, HIGH); digitalWrite(10, HIGH); digitalWrite(13, LOW); analogWrite(9, 255); analogWrite(10, 255); }
Wireless Version of Mind Controlled Robot using Arduino and Bluetooth Module
The same can be made wireless by intercepting the bluetooth signal by employing a HC12 Bluetooth module or incorporating a ZigBee in Transmitter and Receiver Units.
Full tutorial for wireless version of the Mind Controlled Robot using Arduino will be posted soon.
please what is connected to the A1 A2,…,A3 analog pins
those are for the switches that are connected on the main control board.
thank you so much. Please what are the switches used for? and i am a bit confused with the switch function
Plz make a full tutorial on how to make it completely….