I think what you need is similar to the example on https://www.espruino.com/MicroBit#micro-bit-functionality. Something like this should work
g = Graphics.createArrayBuffer(5,5,1); g.flip = function(){show(this.buffer);}; function countdown() { x--; g.clear(); if (x<=0) { // finished clearInterval(intr); intr = undefined; g.fillRect(0,0,5,5); // long beep analogWrite(Microbit.SPEAKER,0.5, {freq:2500}); setTimeout(() => Microbit.SPEAKER.reset(), 500); } else { // count down g.drawString(x); // beep analogWrite(Microbit.SPEAKER,0.5, {freq:3000}); setTimeout(() => Microbit.SPEAKER.reset(), 100); } g.flip(); } var x = 10; countdown(); var intr = setInterval(countdown, 1000);
@Gordon started
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 think what you need is similar to the example on https://www.espruino.com/MicroBit#micro-bit-functionality. Something like this should work