How to use IR remote and LDR as input , and simultaneously Motor control

I have tried running the following . help me out in helping me with code.
What happens with this code is that the LDR works only with the pulse of the IR Remote is there any other possibility available .
My objective is to have the IR remote and LDR both working simultaneously .
int key;
int ldr1;
void ldr();
void remote();
void setup()
{
Serial.begin(9600);
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
}
void loop()
{
Serial.println(ldr1);
Serial.println(key);
ldr();
remote();
}
void ldr()
{
ldr1=analogRead(3);
if(ldr1>600)
{
digitalWrite(12,HIGH);
}
else
{
digitalWrite(12,LOW);
}
}
void remote()
{
while(pulseIn(15,LOW)<2200);
key=0;
for(int i=0;i<7;i++)
{
if(pulseIn(15,LOW)>1000)
key=key+(1<<i);
}
if(key==21)
{
digitalWrite(13,HIGH);
}
else
{
digitalWrite(13,LOW);
}
}

My objective is to have the IR remote and LDR both working simultaneously .

You can forget that, right now. NOTHING happens simultaneously on a single processor system.

You can have things happen one after the other, close enough to be together to be mistaken for simultaneous.

Of course, all that diddling around waiting in remote() is NOT going to allow the function to end, and loop() to be re-run so that the ldr() function can be called.

There ARE successful IRremote libraries around. I see no point in trying to write another one in a blocking fashion.

Thanks for the info :slight_smile: