What will be the reason why the noTone function will be mistaken? or is it wrong?

Code in question______

int pinvoz = 13;
int frec=220;    
int cont;          
float m=1.059;         

void setup()
{
}

void loop()
{
    for(cont=0,frec=220;cont<12;cont++)
  {
  frec=frec*m;    
        tone(pinvoz,frecuencia);
        delay(1500);                 
        noTone(pinvoz);         
        delay(500);                  
    }
}

Like it says, it stops the tone (for 500ms in your code).

In some applications you can use the optional duration parameter with tone() and the tone will stop after that time.

But if I delete it from the code, the next and last delay of the code will mark a mistake.

What do you call a mistake?
What is the actual question?

sketch_jul27a.ino: In function 'void loop()':
sketch_jul27a:15:18: error: 'frecuencia' was not declared in this scope
     tone(pinvoz, frecuencia);
                  ^~~~~~~~~~

Did you mean to use 'frec'?
tone(pinvoz, frec);

yea... is not is not possible?

Try this:

const byte pinvoz = 13;
const float m = pow(2, -12); // Semitone  ~1.059463

float frec = 220.0;

void setup()
{
}

void loop()
{
  frec = 220.0;  // Concert A (440 Hz) one octave down
  for (int cont = 0; cont < 12; cont++)
  {
    frec *= m;  // raise by one semitone
    tone(pinvoz, frec + 0.5);  // play nearest integer frequency
    delay(1500);
    noTone(pinvoz);
    delay(500);
  }
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.