xxxxxxxxxx
25
let port;
let lastValue = 0;
function setup() {
createCanvas(400, 400);
port = createSerial();
}
function draw() {
background(220);
fill(lastValue / 4);
ellipse(200, 200, 200, 200);
let received = port.readUntil("\n");
if (received) {
console.log(received);
lastValue = parseInt(received);
}
}
function mousePressed() {
if (!port.opened()) {
port.open('Arduino', 9600);
}
}