Micro:bit analog read is agonizingly slow?

I think there’s a need for some sort of yield to avoid having other tasks starve, but I’m not sure about the choice of 20ms. Again, I wouldn’t be surprised if it was related to user experience for the most common uses.

One of the nice features of MakeCode is the ability to make extensions. I made an extension that provides “faster” loops: On the V2 one loop is about 250Hz (max) and the other can be 120,000Hz-150,000Hz (120-150kHz) . The URL is: https://github.com/bsiever/pxt-fastloops .

The ... more menu has the block that can go 120-150kHz, but it will still occasionally pause to allow other tasks to run. I included the periodic pause to make starvation of other tasks a little less likely. I think misuse could be a problem. I’m not sure if the loop was the cause, but in one test I had trouble reprogramming the micro:bit over USB and had to use the file drag-and-drop approach.

Bill

1 Like