Elektroenzephalografie
Die Elektroenzephalografie (kurz EEG) ist eine Methode der medizinischen Diagnostik und der neurologischen Forschung zur Messung der summierten elektrischen Aktivität des Gehirns durch Aufzeichnung der Spannungsschwankungen an der Kopfoberfläche.
Mit dem Arduino lässt sich ein solches EEG leicht umsetzen. Man benötigt lediglich einen eigentlich für Spiele gedachten Sensor namens Mindflex. Mit diesem Sensor, welchen man am Kopf trägt, soll man angeblich einen Ball durch einen Parcour mit seinen Gedanken steuern können. Der relevante Chip zur Erfassung der Gehirnwellen stammt von Neurosky.
Als EEG in Verwendung wird die Aktivität in mehreren Gehirnwellenbereichen (Frequenzbereichen) erfasst und kann graphisch etwa in Form eines Diagramms dargestellt werden. Aufgezeichnet werden folgende Bereiche: Attention, Meditation, Delta, Theta, Low Alpha, High Alpha, Low Beta, High Beta, Low Gamma und High Gamma. Ich verwende in meinem Arduinoprogramm im Moment lediglich „Meditation“ und steuere mit den Werten eine LED-Reihe an.
Zur Verbindung mit dem Arduino: Hier müssen lediglich der T-Pin auf der Mindflex-Platine (= TX pin) mit dem RX-Pin am Arduino und GND des Arduinos mit GND der Mindflex-Platine verbunden werden.
Zur Ausführung des Arduino-Programms benötigt man noch eine Brain-library, welche hier erhältlich ist: https://github.com/kitschpatrol/Brain
Unter „examples“ findet man dort auch gleich einen Arduino-sketch mit der Bezeichnung: BrainSerialTest, den man u.a. für den Brain-grapher (siehe weiter unten) benötigt.
Ob nun dieses System wirklich echte Gehirnströme aufzunehmen imstande ist oder nicht muss jeder für sich entscheiden bzw. testen. Eine lustige Spielerei ist es aber mit Sicherheit…
Arduino-Code 1: 9 LEDs und Anzeige von „meditation“
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
// Arduino Brain Library - Brain Serial Test // Description: Grabs brain data from the serial RX pin and sends CSV out over the TX pin (Half duplex.) // More info: https://github.com/kitschpatrol/Arduino-Brain-Library // Author: Eric Mika, 2010 revised in 2014 #include <Brain.h> int meditation; int meditation_LED; int attention; // Set up the brain parser, pass it the hardware serial object you want to listen on. Brain brain(Serial); void setup() { // Start the hardware serial. Serial.begin(9600); pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); } void loop() { // Expect packets about once per second. // The .readCSV() function returns a string (well, char*) listing the most recent brain data, in the following format: // "signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma" if (brain.update()) { //Serial.println(brain.readErrors()); Serial.println(brain.readCSV()); meditation = brain.readMeditation(); attention = brain.readAttention(); Serial.print("Meditation = "); Serial.println(meditation); /* Serial.print(brain.readSignalQuality()); Serial.print(" "); Serial.print(brain.readDelta()); Serial.print(" "); Serial.print(brain.readTheta()); Serial.print(" "); Serial.print(brain.readLowAlpha()); Serial.print(" "); Serial.print(brain.readLowBeta()); Serial.print(" "); Serial.println(brain.readHighBeta()); */ meditation_LED = map(meditation,0,100,0,90); if ((meditation_LED >= 0) && (meditation_LED < 10)) { digitalWrite(2, HIGH); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); digitalWrite(9, LOW); digitalWrite(10, LOW); } if ((meditation_LED >= 10) && (meditation_LED < 20)) { digitalWrite(2, LOW); digitalWrite(3, HIGH); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); digitalWrite(9, LOW); digitalWrite(10, LOW); } if ((meditation_LED >= 20) && (meditation_LED < 30)) { digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, HIGH); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); digitalWrite(9, LOW); digitalWrite(10, LOW); } if ((meditation_LED >= 30) && (meditation_LED < 40)) { digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, HIGH); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); digitalWrite(9, LOW); digitalWrite(10, LOW); } if ((meditation_LED >= 40) && (meditation_LED < 50)) { digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, HIGH); digitalWrite(7, LOW); digitalWrite(8, LOW); digitalWrite(9, LOW); digitalWrite(10, LOW); } if ((meditation_LED >= 50) && (meditation_LED < 60)) { digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, HIGH); digitalWrite(8, LOW); digitalWrite(9, LOW); digitalWrite(10, LOW); } if ((meditation_LED >= 60) && (meditation_LED < 70)) { digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, HIGH); digitalWrite(9, LOW); digitalWrite(10, LOW); } if ((meditation_LED >= 70) && (meditation_LED < 80)) { digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); digitalWrite(9, HIGH); digitalWrite(10, LOW); } if ((meditation_LED >= 80) && (meditation_LED <= 90)) { digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); digitalWrite(9, LOW); digitalWrite(10, HIGH); } } } |
Ich habe noch eine leicht abgeänderte Variante mit Schalter und nur 6 LEDs angefertigt. Damit kann zwischen der LED-Anzeige „meditation“ und „attention“ gewechselt werden.
Arduino-Code 2: 6 LEDs und Schalter
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
// Arduino Brain Library - Brain Serial Test // Description: Grabs brain data from the serial RX pin and sends CSV out over the TX pin (Half duplex.) // More info: https://github.com/kitschpatrol/Arduino-Brain-Library // Author: Eric Mika, 2010 revised in 2014 #include <Brain.h> int meditation; int meditation_LED; int attention; int attention_LED; const int switchPin = 2; int switchState = 0; // Set up the brain parser, pass it the hardware serial object you want to listen on. Brain brain(Serial); void setup() { // Start the hardware serial. Serial.begin(9600); pinMode(switchPin, INPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); digitalWrite(3, HIGH); delay(200); digitalWrite(3, LOW); digitalWrite(4, HIGH); delay(200); digitalWrite(4, LOW); digitalWrite(5, HIGH); delay(200); digitalWrite(5, LOW); digitalWrite(6, HIGH); delay(200); digitalWrite(6, LOW); digitalWrite(7, HIGH); delay(200); digitalWrite(7, LOW); digitalWrite(8, HIGH); delay(200); digitalWrite(8, LOW); delay(1000); } void loop() { // Expect packets about once per second. // The .readCSV() function returns a string (well, char*) listing the most recent brain data, in the following format: // "signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma" if (brain.update()) { //Serial.println(brain.readErrors()); Serial.println(brain.readCSV()); meditation = brain.readMeditation(); attention = brain.readAttention(); Serial.print("Meditation = "); Serial.print(meditation); Serial.print(" , Attention = "); Serial.println(attention); /* Serial.print(brain.readSignalQuality()); Serial.print(" "); Serial.print(brain.readDelta()); Serial.print(" "); Serial.print(brain.readTheta()); Serial.print(" "); Serial.print(brain.readLowAlpha()); Serial.print(" "); Serial.print(brain.readLowBeta()); Serial.print(" "); Serial.println(brain.readHighBeta()); */ switchState = digitalRead(switchPin); if (switchState == HIGH) { meditation_LED = map(meditation,0,100,0,60); if ((meditation_LED >= 0) && (meditation_LED < 10)) { digitalWrite(3, HIGH); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); } if ((meditation_LED >= 10) && (meditation_LED < 20)) { digitalWrite(3, LOW); digitalWrite(4, HIGH); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); } if ((meditation_LED >= 20) && (meditation_LED < 30)) { digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, HIGH); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); } if ((meditation_LED >= 30) && (meditation_LED < 40)) { digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, HIGH); digitalWrite(7, LOW); digitalWrite(8, LOW); } if ((meditation_LED >= 40) && (meditation_LED < 50)) { digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, HIGH); digitalWrite(8, LOW); } if ((meditation_LED >= 50) && (meditation_LED <= 60)) { digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, HIGH); } } else { attention_LED = map(attention,0,100,0,60); if ((attention_LED >= 0) && (attention_LED < 10)) { digitalWrite(3, HIGH); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); } if ((attention_LED >= 10) && (attention_LED < 20)) { digitalWrite(3, LOW); digitalWrite(4, HIGH); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); } if ((attention_LED >= 20) && (attention_LED < 30)) { digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, HIGH); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); } if ((attention_LED >= 30) && (attention_LED < 40)) { digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, HIGH); digitalWrite(7, LOW); digitalWrite(8, LOW); } if ((attention_LED >= 40) && (attention_LED < 50)) { digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, HIGH); digitalWrite(8, LOW); } if ((attention_LED >= 50) && (attention_LED <= 60)) { digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, HIGH); } } } } |
Möchte man sich die Signale mit dem Brain-grapher ansehen, benötigt man ein Processing-Programm, welches hier zur Verfügung gestellt wird: https://github.com/kitschpatrol/BrainGrapher
Zitat: „This is a simple Processing application for graphing changes in brain waves over time. It’s designed to read data from a hacked MindFlex EEG headset connected via USB.
It’s mostly a proof of concept, demonstrating how to parse serial packets from the Arduino Brain Library, monitor signal strength, etc.
BrainGrapher.pde
is the main project file. Open this in the Processing PDE to work with the project.
Attention: You may need to modfiy the index value in the line serial = new Serial(this, Serial.list()[0], 9600);
inside the app’s setup()
function file depending on which serial / USB port your Arduino is connected to. (Try Serial.list()[1]
, Serial.list()[2]
, Serial.list()[3]
, etc.)“.
Auf dem Arduino muss dann folgender Code ablaufen:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
// Arduino Brain Library - Brain Serial Test // Description: Grabs brain data from the serial RX pin and sends CSV out over the TX pin (Half duplex.) // More info: https://github.com/kitschpatrol/Arduino-Brain-Library // Author: Eric Mika, 2010 revised in 2014 #include <Brain.h> // Set up the brain parser, pass it the hardware serial object you want to listen on. Brain brain(Serial); void setup() { // Start the hardware serial. Serial.begin(9600); } void loop() { // Expect packets about once per second. // The .readCSV() function returns a string (well, char*) listing the most recent brain data, in the following format: // "signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma" if (brain.update()) { Serial.println(brain.readCSV()); } } |