xxxxxxxxxx
32
// Visualization of data from EVM board:
// https://github.com/mitmedialab/TI_EVM_logger
var host = 'localhost:8080';
var socket;
var SensorValues = [];
function setup() {
createCanvas(600, 600);
socket = new WebSocket('ws://' + host);
socket.onmessage = readMessage;
}
function readMessage(event) {
// make an array of strings:
SensorValues = split(event.data, ',');
println(SensorValues); // use the data...
}
// visualization with 4 circles moving in function of the data
function draw() {
background(255);
for (i=0; i<4; i++) {
x = map(float(SensorValues[i]), 0,100, width-10,10)%width;
y = map(i, 0,3, height/8, 7*height/8);
ellipse(x,y, 30,30);
}
}