How to merge 2 coding together?

I want to merge this 2 coding for my school project . Can somebody help me or guide me how to merge both of this code into one coding.

LDR :

int ldrPin = A0;
unsigned int ldrValue = 0;

void setup()
{
pinMode(13, OUTPUT);

Serial.begin(9600);
}
void loop()
{

ldrValue = analogRead(ldrPin);
if(ldrValue<900) digitalWrite(13, HIGH);
else digitalWrite(13, LOW);
}

Fish Feeder:

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position

long FISHFEEDER = 2000; // 12 hours between feeding
long endtime;
long now;

void setup()
{

myservo.attach(9); // attaches the servo on pin 9 to the servo object

myservo.write(0);
delay(15);

}

void loop()
{
now = millis();
endtime = now + FISHFEEDER;

while(now < endtime) {
myservo.write(0);
delay(20000);
now = millis();
}

for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
}

What do you want the combined program to do?

This Simple Merge Demo may be helpful.

...R

ChrisTenone:
What do you want the combined program to do?

i want the program to feed the fish at the time(fish feeding) and the lamp in the aquarium light up when it doesnt not detect light from the outside(LDR) like automatic lamp. actually,the fish feeding and the LDR coding has nothing to do with each other,im just want to combined the 2 coding into 1 coding because i has only 1 arduino. i want to make it has dual function in 1 coding for my school project.

#sorry for my rip english,hope you can understand

If you want your program to respond to the LDR properly you will need to replace the delay(20000) in the feeder sketch with a non blocking timing method like Blink WithOut Delay (see IDE Examples, Digital) or several things at a time.

can somebody help me to merge both of this code? because i did not have much time and i have to submit it by tomorrow :cry: i have tried many times and having so much failure.

Lets see. You may, or may not, have read reply #1. If you did, you failed to respond to it.

You may, or may not, have made some attempt to combine the two programs. If you did, you failed to post your attempt or to provide any explanation of what the code actually does, and how that differs from what you expect, or how your expectations differ from what you want.

So, I'd have to say no, we can't help you.

“now” will always be < “endtime” because endtime = now + FISHFEEDER

No reason to make now == millis() at the end of loop() then again at the top

Your for statements will never run because they are outside any function