xxxxxxxxxx
37
let x=0;
function setup() {
createCanvas(640, 480);
}
function draw() {
background(255);
fill(0);
textSize(18);
if (!serialActive) {
text("Press Space Bar to select Serial Port", 20, 30);
} else {
text("Connected", 20, 30);
}
fill(255,0,0)
stroke(0)
ellipse(map(x,0,1023,0,width),height/2,100,100)
}
function keyPressed() {
if (key == " ") {
setUpSerial();
}
}
function readSerial(data) {
if (data != null) {
let fromArduino = trim(data);
x = int(fromArduino);
}
}