xxxxxxxxxx
25
let lecture;
let val = 0;
function setup() {
serial = new p5.SerialPort();
serial.open("COM11");
serial.on('data', gotData);
createCanvas(400, 400, WEBGL);
}
function draw() {
background(20);
directionalLight(val, val, 0, 1, 1, -1)
fill(255);
noStroke();
sphere(100);
}
function gotData() {
lecture = serial.readStringUntil('\n');
if(lecture) {
lecture = int(lecture)
//console.log(val)
val = map(lecture, 0, 1023, 0, 300);
}
}