How to reduce the audio volume from highest to lowest (0) in 2 seconds without a potentiometer?

// This code uses the built-in analogWrite() function to control the volume of an audio output pin.
// The volume will decrease from the highest value (250) to the lowest value (0) in 2 seconds.

int audioPin = 9; // define the audio output pin

void setup() {
pinMode(audioPin, OUTPUT); // set the audio output pin as an output
}

void loop() {
for (int i = 250; i >= 0; i--) { // loop from highest value (250) to lowest value (0)
analogWrite(audioPin, i); // set the volume to the current value
delay(8); // wait for 8 milliseconds (2 seconds / 255 steps)
}
}

Do you have a question? Also see the pinned post about how to get the best out of the forum. HINT, your code is posted wrong.

I only see a PWM output sweeping from max to min.
Where is the audio signal?

This should be 250.

Topic closed to prevent anyone else wasting time on it.

@saurav_satpathy-1403 please see the PM I have sent you and please follow the forum guide before posting anything else.