@halemmerich, yes, I saw your post for the custom case. That looks pretty good.
Here is the function to drive the piezo.
function piezoBuzz(pin, frequency, times, duration, pause) { let count = 0; function buzz() { if (count < times) { analogWrite(pin, 0.5, { freq: frequency }); setTimeout(() => { analogWrite(pin, 0); setTimeout(() => { count++; buzz(); }, pause); }, duration); } } buzz(); }
And here is an example to call the function.
piezoBuzz(D43, 5600, 2, 200, 200); //UATX pin, 5.6kHz, twice, 200ms pulse, 200ms pause
@JeonLab 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.
@halemmerich, yes, I saw your post for the custom case. That looks pretty good.
Here is the function to drive the piezo.
And here is an example to call the function.