How to tell Blynk to 'not' control a pin?

How do I tell blynk ‘not’ to control a pin? I ran a test script with a piezo connected to D5 on my project to play a simple alert tune. As soon as I add blink to the script, I can’t get the tune to play. (I’m running the function from a virtual pin)

All I get a ‘click’ from the piezo when blynk.begin() [setup] and [loop] are added to the code.

#define TONEPIN 5
int melody[] = {
     NOTE_C5, NOTE_G5, NOTE_C5, NOTE_G5,

int noteDurations[] = {
    8, 8, 8, 8,
    8, 8, 8, 8
void playTune() {
    for (int thisNote = 0; thisNote < 8; thisNote++) {
        int noteDuration = 1000 / noteDurations[thisNote];
        tone(TONEPIN, melody[thisNote], noteDuration);

Code snippets don’t help us to understand what you’re doing, but full code and an explanation of your hardware, connections, and app widget setup do.


Are you calling playTune() from your BLYNK_WRITE for that specific virtual pin?



will disable built-in analog and digital operations
Maybe it helps. Give it a try …


I tried calling it from the BLYNK_WRITE directly and also setting a variable and calling it periodically via an asynchronous check of a millis based timer. I can hear the piezo ‘click’ so Tone is trying to play something, but I’m assuming BLYNK is countering whatever tone() is trying to do on the pin in question. I don’t fully understand what BLYNK is doing in the background, but if I remove the blynk code, it works fine.
I have similar problems with the LED. I wanted to create a virtual toggle to notify the async millis loop to ‘blink’ the LED.

I’m trying to build a device to track a cat down when it wanders off. I wanted to be able to turn on/off a blinking LED and/or turn on/off a repeating tone. I’d settle for just playing the tone and/or turning on/off the LED manually from a button and got that to somewhat work with a single tone() call in the BLYNK_WRITE. But now the damn thing won’t connect to the phone when just powered by the 3.7v lipo. If I connect the USB, re-initialize it by re-uploading the sketch, I can then get it to connect, remove the USB and it will continue working. But it’s very temperamental that way - if jostled hard enough, the battery connector may lose contact, re-powering the beetle in which case it won’t connect any more until plugged back into USB and the sketch is re-uploaded again.
I tried a slew of stuff, but the only thing that worked to get it to connect when it stops being responsive is re-uploading the sketch while connected to USB. Not sure what is going on.

And I would still prefer to have the blinking/tone keep going after the button is pressed like a toggle. So we wouldn’t have to be constantly pressing the button on the blynk app while trying to find under which bush the mischievous minx is hiding under.