Help with pressure sensor

Hey guys, I’m working on a small project and ran into a problem. My goal is to check of the output from the sensor is greater than 4.5, and if it is, a tune will play once, and an led will stay lit up until the sensor is let go. However, by holding the sensor, the tune will play on loop, How can I get the tune to play once, but still have the LED stay on?

Here’s some code that I have written:

int holding;

void setup() {
Serial.begin(9600);
pinMode(8, OUTPUT);

}

void loop() {
int sensorValue = analogRead(A1);
float voltage = sensorValue * (5.0 / 1023.0);
if(voltage >= 4.50){
call2();
delay(200);
test();
}
}
void test(){
delay(500);
int sensorValue = analogRead(A1);
float voltage = sensorValue * (5.0 / 1023.0);
if(voltage < 1){
digitalWrite(8, HIGH);
delay(500);
digitalWrite(8, LOW);
}
}
void call2(){
holding = 1;
delay(500);
if(holding==1){
digitalWrite(8, HIGH);
delay(500);
digitalWrite(8, LOW);
delay(500);
digitalWrite(8, HIGH);
delay(500);
digitalWrite(8, LOW);
delay(500);
digitalWrite(8, HIGH);
delay(500);
digitalWrite(8, LOW);
holding = 0;
delay(1000);
}
}

In no way is this code done, but it’s what I tried to do to test this.

Thanks

How can I get the tune to play once,

Create a global or static boolean variable, let's call it tunePlayed and set it to false. Before you play the tune check tunePlayed and only proceed if it is false. When the tune has been played set tunePlayed to true

Why you only run the code inside the function 'call2' if the variable 'holding' is one? I don't see any logic in that.

Take a look to the forum rules and learn how to post code properly.