Created
June 7, 2012 14:24
-
-
Save kitschpatrol/2889071 to your computer and use it in GitHub Desktop.
Rough skeleton code for going from the b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import processing.serial.*; | |
| Serial serial; | |
| // TODO Import OSC library | |
| int packetCount = 0; | |
| void setup() { | |
| // Set up serial connection | |
| println("Find your Arduino in the list below, note its [index]:\n"); | |
| println(Serial.list()); | |
| serial = new Serial(this, Serial.list()[0], 9600); | |
| serial.bufferUntil(10); | |
| // TODO set up OSC stuff | |
| } | |
| void draw() { | |
| // Nothing to see here | |
| } | |
| void serialEvent(Serial p) { | |
| // Split incoming packet on commas | |
| // See https://github.com/kitschpatrol/Arduino-Brain-Library/blob/master/README for information on the CSV packet format | |
| String[] incomingValues = split(p.readString(), ','); | |
| // Verify that the packet looks legit | |
| if (incomingValues.length > 1) { | |
| packetCount++; | |
| // Wait till the third packet or so to start recording to avoid initialization garbage. | |
| if (packetCount > 3) { | |
| int signalQuality = Integer.parseInt(incomingValues[0].trim()); | |
| int attention = Integer.parseInt(incomingValues[1].trim()); | |
| int meditation = Integer.parseInt(incomingValues[2].trim()); | |
| int delta = Integer.parseInt(incomingValues[3].trim()); | |
| int theta = Integer.parseInt(incomingValues[4].trim()); | |
| int lowAlpha = Integer.parseInt(incomingValues[5].trim()); | |
| int highAlpha = Integer.parseInt(incomingValues[6].trim()); | |
| int lowBeta = Integer.parseInt(incomingValues[7].trim()); | |
| int highBeta = Integer.parseInt(incomingValues[8].trim()); | |
| int lowGamma = Integer.parseInt(incomingValues[9].trim()); | |
| int highGamma = Integer.parseInt(incomingValues[10].trim()); | |
| // TODO take the above values and send them out over OSC | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment