Stop Reading Sensor Value

I’m creating a fairly simple project in which a threshold is set to a voice module sensor. When the threshold is reached, it turns an led 7-color flasher light on. The issue I am having is that when the threshold is reached, I want the light to remain on, and be able to adjust either the brightness of the light or the frequency at which it blinks, using a potentiometer. However, I am unsure of how to do that.

Another alternative I was thinking of was once the threshold was reached, the light would automatically turn on and sensor values would no longer be read from the voice sensor. That way the potentiometer and light could function independently. Does anyone have any idea how I could do that? I’m a beginner at Arduino coding, so keep it simple if you can.

Here’s how my code looks:

//Declare Variables
int soundPin = A3;
int ledPin = 10;
int SoundValue = 0;

int potentiometerPin = A0;
int sensorValue = 0;

void setup() //runs once

pinMode(potentiometerPin, OUTPUT); //declares potentiometerPin as an OUTPUT;

pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
Serial.begin(9600); // initialize serial communication with computer

void potent()
// read the value from the sensor:
//sensorValue = analogRead(potentiometerPin);

// read the value from the sensor:
sensorValue = analogRead(potentiometerPin); //read potentiometer

//turn the ledPin on
digitalWrite(ledPin, HIGH);
//stop the program for milliseconds:
//turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for milliseconds:


void loop() //runs constantly
SoundValue = analogRead(soundPin); // read the value from the sensor
Serial.println(SoundValue, DEC); // send it to the computer (as ASCII digits)

if (SoundValue > 40)
digitalWrite(ledPin, HIGH); // turn the ledPin on
// delay(900); // stop the program for some time

//digitalWrite(ledPin, LOW); // turn the ledPin off
// delay(300); // stop the program for some time

potent(); //not too sure where I was going with this. I tried using an “if” statement to adjust the light while the light was on.

Please - use code tags when posting code (# button above the smileys) - use CTRL-T before copying your code (auto formatting makes code more readable)

you must make a small state machine that in the first state it shows current behavior and in the second it does the next