0

I am new to Arduino, and right now I am trying to generate a frequency that gradually decreases (without using the tone library) in a program that gradually increases the delay between the switching of the high and low. I have the arduino connected to an audio amp and a speaker.

For some reason, the speaker only outputs a single tone and I dont know why. Here is the code:

    void setup()
    {
      pinMode(3, OUTPUT);
    }

    void loop()
    {
      for (int i=100; i <= 25500; i+100){
        digitalWrite(3, HIGH);
        delayMicroseconds(i); 
        digitalWrite(3, LOW);
        delayMicroseconds(i);
      }
    }

Any help would be appreciated. I would prefer to try and do this the way I am doing, as opposed to using a completly different method or the tone library.

L. Z
  • 27
  • 1
  • 1
  • 5

1 Answers1

1

There is an error in the for statement: the increment statement is actually not a statement. You need to assign i to the new value, i.e. write i = i + 100 instead of just i + 100.

noearchimede
  • 188
  • 9