xxxxxxxxxx
38
function setup() {
createCanvas(640, 360);
}
function draw() {
background(255);
if (!serialActive) {
text("Press up arrow to select Serial Port", 20, 30);
} else {
text("Connected", 20, 50);
}
}
function keyPressed(){
if (keyCode == UP_ARROW) {
// important to have in order to start the serial connection!!
setUpSerial();
}
}
function readSerial(Data) {
if(Data != null) {
let fromArduino = split(trim(Data), ",");
if (fromArduino.length == 4) {
// only store values here
// do everything with those values in the main draw loop
fs1 = int(fromArduino[0]);
fs2 = int(fromArduino[1]);
fs3 = int(fromArduino[2]);
button = int(fromArduino[3]);
}
}
}