NeuroMagabot (Processing + EPOC Neuroheadset + Magabot)
/** | |
* NeuroMagabot | |
* | |
* Transforms data from the Emotiv EPOC neuroheadset | |
* into control data for the Magabot, via OSC. | |
* see https://github.com/Magabot | |
*/ | |
import processing.serial.*; | |
import oscP5.*; | |
import netP5.*; | |
Serial port; | |
OscP5 oscP5; | |
float thresh = 0.25; // one threshold for all Cognitiv values | |
void setup() { | |
size(200, 200); | |
println(Serial.list()); | |
port = new Serial(this, Serial.list()[0], 9600); | |
//start oscP5, listening for incoming messages at port 7400 | |
//make sure this matches the port in Mind Your OSCs | |
oscP5 = new OscP5(this, 7400); | |
// plug the messages for the Cognitiv values | |
oscP5.plug(this,"sendW","/COG/PUSH"); | |
oscP5.plug(this,"sendS","/COG/PULL"); | |
oscP5.plug(this,"sendA","/COG/LEFT"); | |
oscP5.plug(this,"sendD","/COG/RIGHT"); | |
} | |
void draw() { | |
// here you could graph the EPOC data, draw an animated face on the laptop screen, etc. | |
} | |
public void sendW(float val) { | |
if (val >= thresh) { | |
port.write('w'); // send move-forward command to Arduino | |
} else { | |
port.write('p'); // send stop command | |
} | |
} | |
public void sendS(float val) { | |
if (val >= thresh) { | |
port.write('s'); // send move-reverse command to Arduino | |
} else { | |
port.write('p'); | |
} | |
} | |
public void sendA(float val) { | |
if (val >= thresh) { | |
port.write('a'); // send turn-left command to Arduino | |
} else { | |
port.write('p'); | |
} | |
} | |
public void sendD(float val) { | |
if (val >= thresh) { | |
port.write('d'); // send turn-right command to Arduino | |
} else { | |
port.write('p'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment