@allObjects yes, you could go all out trying to use the built-in hardware on 8 channels simultaneously to get really accurate results... Because you're just measuring pulse lengths you can use @ClearMemory041063's code (or this for the Pico) as is (without having to have anything running on interrupt), because you don't care if you miss a reading or not (the latest value will always be in the register).
OR you could just do what the Arduino code does, which only needs 4 lines of code and works on any pin:
function getLight(pin) {
var c=0;
pin.set();
while(pin.read())c++;
return c;
}
I reckon that would work relatively well - you might get one or two glitchy readings but on the whole it'd be good enough.
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.
@allObjects yes, you could go all out trying to use the built-in hardware on 8 channels simultaneously to get really accurate results... Because you're just measuring pulse lengths you can use @ClearMemory041063's code (or this for the Pico) as is (without having to have anything running on interrupt), because you don't care if you miss a reading or not (the latest value will always be in the register).
OR you could just do what the Arduino code does, which only needs 4 lines of code and works on any pin:
I reckon that would work relatively well - you might get one or two glitchy readings but on the whole it'd be good enough.