Issue driving piezo

Posted on
  • I have a little piezo I am turning on by
    analogWrite(A5, 0.5, { freq: f } );

    While I am debugging and connected to USB it works fine. When I disconnect USB and leave it to run on battery it sounds but does a funny chirp - I assume the PWM is getting messed up somehow.

    I dont have a scope to check what is going on - any ideas ? Anything to do with A5 ?

  • Are you using setDeepSleep(1)? Deep sleep turns off the main oscillator (which also turns off PWM), so that could be causing problems? To work around it, just do setDeepSleep(0) whenever you know you'll be driving the piezo, and turn it back on afterwards.

    Otherwise I'm not sure what the issue could be...

  • Yes - deep sleep is set - will try that !

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Issue driving piezo

Posted by Avatar for jonreid @jonreid

Actions