xxxxxxxxxx
33
let magX = 0;
let magY = 0;
let magZ = 0;
let magSensor;
function setup() {
createCanvas(400, 400);
magSensor = new Magnetometer();
magSensor.addEventListener("reading", (e) => {
magX = magSensor.x;
magY = magSensor.y;
magZ = magSensor.z;
});
magSensor.start();
}
function draw() {
//frameRate(2);
background(220);
textSize(42);
fill(255);
noStroke();
text("x : " + magX, 25, 50);
text("y : " + magY, 25, 100);
text("z : " + magZ, 25, 150);
}