-HELP- Photo resistor Coding

int P = 8;
int C = 350;
int D = 400;
int E = 450;
int F = 500;
int G = 550;
int A = 600;
int B = 650;
int C2 = 700;
int D2 = 750;
int O = 1000;
int M = 500;
int N = 2000;

// variable to hold sensor value
int sensorValue;
// variable to calibrate low value
int sensorLow = 1023;
// variable to calibrate high value
int sensorHigh = 0;
// LED pin
const int ledPin = 13;

void setup()
{
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);

// calibrate for the first five seconds after program runs
while (millis() < 5000) {
// record the maximum sensor value
sensorValue = analogRead(A0);
if (sensorValue > sensorHigh) {
sensorHigh = sensorValue;
}
// record the minimum sensor value
if (sensorValue < sensorLow) {
sensorLow = sensorValue;
}
}
// turn the LED off, signaling the end of the calibration period
digitalWrite(ledPin, LOW);

}
void playTone(){
tone(P, D, M);
delay(500);
tone(P, D, M);
delay(500);
tone(P, E, O);
delay(1000);
tone(P, D, O);
delay(1000);
tone(P, G, O);
delay(1000);
tone(P, F, N);
delay(2000);
tone(P, D, M);
delay(500);
tone(P, D, M);
delay(500);
tone(P, E, O);
delay(1000);
tone(P, D, O);
delay(1000);
tone(P, A, O);
delay(1000);
tone(P, G, N);
delay(2000);
tone(P, D, M);
delay(500);
tone(P, D, M);
delay(500);
tone(P, D2, O);
delay(1000);
tone(P, B, O);
delay(1000);
tone(P, G, O);
delay(1000);
tone(P, F, O);
delay(1000);
tone(P, E, O);
delay(1000);
tone(P, C2, M);
delay(500);
tone(P, C2, M);
delay(500);
tone(P, B, O);
delay(1000);
tone(P, G, O);
delay(1000);
tone(P, A, O);
delay(1000);
tone(P, G, N);
delay(2000);

}
void loop()
{
sensorValue = analogRead(A0);//check sensor
if (sensorValue <=sensorHigh){//check if has seen a shadow
playTone();//play song
sensorValue=10000;//reset the sensor
}

}

Ok so this is my Coding for my arduino,and I couldnt get photoresistor working.
I wanted so that if I put my hand over the sensor it stops the song. and off = resume or restart song.
It is similar to Ex"LightThermin" but I couldnt use that for the Project I was trying to do.
Please contact me for help. ( Josephshin0813@gmail.com ) thank you so much.

It is a very bad idea to use your email address as your username. It will be exposed to all sort of spammers.

If you want a responsive program you need to get rid of ALL the delay()s because the Arduino can do nothing during a delay(). Have a look at how millis() is used to manage timing without blocking in Several things at a time

And please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

…R

You can calibrate the sensor continuously, inside loop(), so that sensorHigh and sensorLow will track the maximum and minimum values of the LDR signal. Then determine the threshold value, above and below which the LDR is considered covered/uncovered, e.g. in the middle of both limits.