xxxxxxxxxx
30
let serial;
let bright = 0;
function setup() {
createCanvas(500, 500);
dark = color(0);
light = color(255, 204, 0);
serial = new p5.SerialPort();
serial.open('/dev/tty.usbmodem2101');
}
function draw() {
background(0);
fill(255, 43, 28);
stroke(255);
strokeWeight(6);
ellipse(250,250,250,250);
stroke(255);
strokeWeight(3);
noFill();
ellipse(mouseX, mouseY, 10, 10);
}
function mouseClicked(){
bright = floor(map(mouseY, 0, 500, 0, 500));
bright = constrain(bright, 0, 255);
serial.write(bright);
console.log(bright);
}