xxxxxxxxxx
32
let theSqaure;
let squareState = false;
let connection = new SerialConnection();
function setup() {
connection.init()
theSquare = createCanvas(240, 240);
background(220);
fill(0);
stroke(255);
rect(40, 40, 160, 160);
theSquare.mousePressed(toggleSquare);
}
function toggleSquare() {
background(220);
if (squareState) {
fill(0);
stroke(255);
connection.write('on');
squareState = false;
} else {
fill(255);
stroke(0);
connection.write('off');
squareState = true;
}
theSquare = rect(40, 40, 160, 160);
}
function draw() {
}