i'm prototyping something for my students
i use a V53L1X connected to my pico.
i would like to transfer the datas to Processing.
i connect the Pico on the usb plug.
should i use console.log or print
to transmit my data?
should i initialize a serial port? Serial1.setup(115200);
some time the console send error from the program (i2c init);
i'm really confuse, it should be simple, but it's not.
sometime nothing arrive to Processing.
i've got an other problem, the string received start with an invisible char and [J
How should i do to have a clean string with distance value?
Could i use midi thru usb to send datas?
i should split my value [0-4000] in 2 set of 7bits (midi value)
thanks for your help
éric
let laser;
function lis(){
let somme=0;
var dist = laser.performSingleMeasurement().distance;
//print(dist);
console.log(dist);
//console.log("distance: ",dist," lissée:",somme/table.length);
analogWrite(LED1, (300-dist)/300, { soft:true, freq:200 });
}
function onInit() {
Serial1.setup(115200);
I2C2.setup({sda:B3,scl:B10});
laser = require("VL53L1X").connect(I2C2);
console.log("init");
digitalWrite(B4,1); // set XSDN -> turn the sensor on
setInterval(lis, 80);
}
and the processing sketch
import processing.serial.*;
Serial myPort; // Create object from Serial class
int val; // Data received from the serial port
void setup()
{
size(200, 200);
// le port de l'espruino sur mon mac est en 3
String portName = Serial.list()[3];
myPort = new Serial(this, portName, 115200);
}
void draw(){
while (myPort.available() > 0) {
String inBuffer = myPort.readStringUntil('\r');
if (inBuffer != null) {
String[] q = splitTokens(inBuffer, "[J");
if (q.length > 1) {
val = int(float(q[1]));
println(val);
}
}
}
}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I know this certainly a stupid question.
i'm prototyping something for my students
i use a V53L1X connected to my pico.
i would like to transfer the datas to Processing.
i connect the Pico on the usb plug.
should i use
console.log
orprint
to transmit my data?
should i initialize a serial port?
Serial1.setup(115200);
some time the console send error from the program (i2c init);
i'm really confuse, it should be simple, but it's not.
sometime nothing arrive to Processing.
i've got an other problem, the string received start with an invisible char and
[J
How should i do to have a clean string with distance value?
Could i use midi thru usb to send datas?
i should split my value [0-4000] in 2 set of 7bits (midi value)
thanks for your help
éric
and the processing sketch