WEEK 11
INTERFACE
MADE TWO BARS TO SHOW ATTENTION AND MEDITATION BRAINWAVE LEVELS WITH MINDFLEX SENSOR
import processing.serial.*;
import controlP5.*;
ControlP5 controlP5;
Serial port;
String inString;
int packetCount = 0;
float c_att = 10;
float c_med = 50;
float signal = 0;
float att = 150;
float med = 150;
void setup() {
// Set up window
size(400, 768);
frameRate(60);
port = new Serial(this, "/dev/cu.usbserial-00002014", 9600);
port.bufferUntil('\n');
}
void draw() {
background(0);
//att
fill(#ff0000);
rect(100, 500 - att, 80, 500);
//med
fill(#ffffff);
rect(200, 500 - med, 80, 500);
}
void serialEvent(Serial port) {
String inString = port.readStringUntil('\n');
if (inString != null);{
inString = trim(inString);
float [] val = float(split(inString, ","));
if (val.length >= 3){
signal = val[0];
att = val[1];
att = map(att, 0, 100, 0, 250);
med = val[2];
med = map(med, 0, 100, 0, 250);
}
}
}
MADE ANOTHER ONE THAT WITH CIRCLES THAT CHANGE COLOR WHEN YOU LOOK AT THE OTHER CIRCLE (complete self projection)
THE CODE WAS OPENSOURCE I ALTERED IT IN PROCESSING AND MADE A LESSER VERSION OF IT
ORIGINAL CODE