Info page · no simulation · Arduino and electronics
Brain-Controlled Wheelchair (Learning Model)
How a headset that reads brain waves (EEG) can steer a small robot chair with an Arduino, and why safety checks come first.
This topic cannot be run safely or meaningfully in the simulator, so this page explains it with diagrams, calculations and sample code instead. Everything here is original.
What you will learn
- What an EEG headset measures and outputs
- How attention values can start and stop a model chair
- Why sensors must always be able to override the brain signal
In short
A consumer EEG headset such as the NeuroSky MindWave measures tiny electrical signals from the forehead. It sends numbers by Bluetooth: an attention level from 0 to 100, a meditation level, and a signal quality value. The Arduino reads the numbers and turns them into drive commands. An ultrasonic sensor can always stop the chair, because EEG signals are noisy.
Try this next
- Use eye blinks (blink strength) as a second command to turn.
- Add an emergency stop button.
- Add a speed limit that rises slowly with attention.
Safety: this page describes a learning model on a small robot car. A real wheelchair is a medical device. It needs certified motors, brakes, an emergency stop and clinical testing. Do not carry a person on a home-made model.
System diagram
The headset sends packets of numbers (the ThinkGear protocol) many times a second. The Brain library for Arduino decodes them. A Mega is best because it has extra serial ports for the Bluetooth module, leaving the USB serial for debugging.
Decision rules
- If the signal quality is not 0 (the electrodes do not touch well), stop.
- If attention is above 60 for about 1 second, drive forward slowly.
- If attention drops below 40, stop.
- If an obstacle is nearer than 40 cm, stop whatever the brain signal says.
- If the emergency button is pressed, stop and stay stopped until reset.
#include <Brain.h>
Brain brain(Serial1); // headset Bluetooth module on Serial1 (Mega)
const int TRIG = 22, ECHO = 23, ESTOP = 24;
unsigned long goSince = 0;
long distanceCm() {
digitalWrite(TRIG, LOW); delayMicroseconds(2);
digitalWrite(TRIG, HIGH); delayMicroseconds(10);
digitalWrite(TRIG, LOW);
long us = pulseIn(ECHO, HIGH, 30000);
return us == 0 ? 400 : us / 58;
}
void driveForward() { /* set your motor driver pins here */ }
void stopMotors() { /* stop both motors */ }
void setup() {
Serial1.begin(57600);
pinMode(TRIG, OUTPUT); pinMode(ECHO, INPUT); pinMode(ESTOP, INPUT_PULLUP);
}
void loop() {
if (digitalRead(ESTOP) == LOW) { stopMotors(); return; } // button to GND = stop
if (brain.update()) {
bool good = brain.readSignalQuality() == 0;
int attention = brain.readAttention();
if (good && attention > 60) { if (goSince == 0) goSince = millis(); }
else if (!good || attention < 40) goSince = 0;
}
bool wantGo = goSince != 0 && millis() - goSince > 1000;
if (wantGo && distanceCm() > 40) driveForward(); else stopMotors();
}Parts list
| Part | What to look for |
|---|---|
| EEG headset (for example NeuroSky MindWave Mobile) | Bluetooth, 57600 baud |
| Arduino Mega 2560 | Needs Serial1 |
| HC-05 Bluetooth module | Paired as master with the headset (set with AT commands) |
| Motor driver and two gear motors | Rated for the motor current |
| Ultrasonic sensor HC-SR04 | Obstacle stop |
| Emergency stop button, buzzer | Always fitted |
| Small robot chassis and battery | Use a fuse |
Do and do not
- Do test on a robot car with the wheels off the floor first.
- Do keep the speed low and fit the emergency stop within easy reach.
- Do remember that attention values change by themselves and are not a reliable control.
- Do not use the model for a person.
- Do not remove the obstacle sensor to make it move faster.