Problem inserting the code for LDR in this code

Hi! I'm a highschool student. We're trying to make an alarm on where when the LDR senses the light, the buzzer will create noises on these specific keys while the LEDs are on but I'm having some difficulty figuring out where to insert the code for the LDR in this one.

const int buzzerPin = 9;

void setup() {

pinMode (buzzerPin, OUTPUT);

}

void loop() {

tone(buzzerPin, 587, 709.720327982);
delay(788.578142202);
tone(buzzerPin, 554, 709.720327982);
delay(788.578142202);
tone(buzzerPin, 493, 273.683002294);
delay(304.092224771);
tone(buzzerPin, 369, 273.683002294);
delay(304.092224771);
tone(buzzerPin, 369, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 369, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 369, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 369, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 369, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 493, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 493, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 493, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 493, 273.683002294);
delay(304.092224771);
tone(buzzerPin, 440, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 493, 273.683002294);
delay(304.092224771);
tone(buzzerPin, 391, 412.843850917);
delay(458.715389908);
tone(buzzerPin, 391, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 391, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 391, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 391, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 391, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 493, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 493, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 493, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 493, 273.683002294);
delay(304.092224771);
tone(buzzerPin, 554, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 587, 273.683002294);
delay(304.092224771);
tone(buzzerPin, 440, 412.843850917);
delay(458.715389908);
tone(buzzerPin, 440, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 440, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 440, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 440, 41.7482545872);
delay(46.3869495413);
tone(buzzerPin, 440, 37.109559633);
delay(41.2328440367);
tone(buzzerPin, 440, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 587, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 587, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 587, 46.3869495413);
delay(51.5410550459);
delay(30.9246330275);
tone(buzzerPin, 587, 46.3869495413);
delay(51.5410550459);
delay(20.6164220183);
tone(buzzerPin, 587, 273.683002294);
delay(304.092224771);
tone(buzzerPin, 659, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 659, 273.683002294);
delay(304.092224771);
tone(buzzerPin, 554, 691.165548165);
delay(767.961720183);
tone(buzzerPin, 587, 552.004699541);
delay(613.338555046);
tone(buzzerPin, 554, 552.004699541);
delay(613.338555046);
tone(buzzerPin, 493, 273.683002294);
delay(304.092224771);
tone(buzzerPin, 369, 273.683002294);
delay(304.092224771);
tone(buzzerPin, 369, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 369, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 369, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 369, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 369, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 493, 46.3869495413);
delay(51.5410550459);
tone(buzzerPin, 493, 46.3869495413);
delay(51.5410550459);
tone(buzzerPin, 493, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 493, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 493, 273.683002294);
delay(304.092224771);
tone(buzzerPin, 440, 134.52215367);
delay(149.469059633);
tone(buzzerPin, 493, 273.683002294);
delay(304.092224771);

}

Thank you for your time!
(This code isn't mine)

What on earth are all these precise delays etc....

delay(788.578142202);

looks like someone used an online calculator

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Forget the code you have there as it will only cause you problems.
First work on getting the LDR to input to the controller.

What model Arduino controller do you have?

This will help you understand how to do it.

https://create.arduino.cc/projecthub/tarantula3/using-an-ldr-sensor-with-arduino-807b1c?f=1

Get this working then google arduino buzzer code

What is the buzzer you have?

Thanks.. Tom.. :slight_smile:

(This code isn't mine)

Then why did you claim that it is the code you are using?

It is really simple to insert the code for the LDR in that code. Let's assume that the LDR is connected to analog pin 3.

void loop()
{
   int ldrValue = analogRead(3);

   // The rest of your code with the silly delays goes here
}

Now, doing something with the value read from the pin is a whole different story. But, you seem to have forgotten to say what your requirements are.

Cams1113:
tone(buzzerPin, 493, 273.683002294);
delay(304.092224771);

All those decimals do precisely nothing as they'll be discarded upon compilation. This as these functions only take integer values...