Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Rough skeleton code for going from the b
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");
serial = new Serial(this, Serial.list()[0], 9600);
// TODO set up OSC stuff
void draw() {
// Nothing to see here
void serialEvent(Serial p) {
// Split incoming packet on commas
// See for information on the CSV packet format
String[] incomingValues = split(p.readString(), ',');
// Verify that the packet looks legit
if (incomingValues.length > 1) {
// 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
You can’t perform that action at this time.