Unable to Update Analoge Voltage of Photoresistor

Hello! I'm trying to get a program to act the way I want it to. I'm trying to make it so that when the button from the remote control is pressed, the code starts reading the photoresistor value and constantly refreshes that value, and depending on what that value is a set of LEDs turn on or off. Currently the code runs as follows, I can press the button on the remote and the photoresistor value is read, but if the value of the photoresistor is changed it's not updated unless the remote button is pressed again. The code works the way I want it to only when the code for the IR sensor is removed. The first set of codes includes the IR sensor and doesn't let the photoresistor update it's value, while the second set of codes doesn't include the IR sensor but has the photoresistor working the way I want it too. I have also attached a simple schematic of the project. Thank you!

FIRST SET OF CODES:

#include <IRremote.h> // Infrared remote library 
int RECV_PIN = 11;
int GreenLED = 10;
int YellowLED = 12;
int RedLED = 13;
int sensorPin = A0; 
int sensorValue = 0;

IRrecv irrecv(RECV_PIN); //Create the receiver object
decode_results results; //When a signal is received, information is stored into "results"

void setup(){
irrecv.enableIRIn(); //Begin the receiving IR Signal 
pinMode(RedLED, OUTPUT);
pinMode(YellowLED,OUTPUT);
pinMode(GreenLED,OUTPUT);
digitalWrite(RedLED, LOW);
digitalWrite(YellowLED, LOW);
digitalWrite(GreenLED, LOW);
}

void loop() {

if (irrecv.decode(&results)) {
irrecv.resume(); //After receiving, this must be called to reset the receiver and prepare it to receive another signal
sensorValue = analogRead(sensorPin); //reads value of Photoresistor

if (results.value == 0xFF30CF){  //activates code when this signal is received
if(sensorValue < 600){ // if light shining on photoresistor red and yellow LED turn on
digitalWrite(RedLED, HIGH);
digitalWrite(GreenLED, LOW);
digitalWrite(YellowLED, HIGH);
sensorValue = analogRead(sensorPin); //reads value of Photoresistor
}
else{  // if no light shining on photoresistor green led LED turn on
digitalWrite(RedLED, LOW);
digitalWrite(GreenLED, HIGH);
digitalWrite(YellowLED, LOW);
sensorValue = analogRead(sensorPin); //reads value of Photoresistor
}}}}

SECOND SET OF CODES:

int GreenLED = 10;
int YellowLED = 12;
int RedLED = 13;
int sensorPin = A0; 
int sensorValue = 0;

void setup(){
pinMode(RedLED, OUTPUT);
pinMode(YellowLED,OUTPUT);
pinMode(GreenLED,OUTPUT);
digitalWrite(RedLED, LOW);
digitalWrite(YellowLED, LOW);
digitalWrite(GreenLED, LOW);
}

void loop() {
sensorValue = analogRead(sensorPin);  //reads value of Photoresistor

if(sensorValue < 600){ // if light shining on photoresistor red and yellow LED turn on
digitalWrite(RedLED, HIGH);
digitalWrite(GreenLED, LOW);
digitalWrite(YellowLED, HIGH);
sensorValue = analogRead(sensorPin); //reads value of Photoresistor
}
else{  // if no light shining on photoresistor green led LED turn on
digitalWrite(RedLED, LOW);
digitalWrite(GreenLED, HIGH);
digitalWrite(YellowLED, LOW);
sensorValue = analogRead(sensorPin);  //reads value of Photoresistor
}}

your code is in readable - lay it out and then repost it!

Bit I think is says only read the ADc if the button has just been pushed.

Mark

You use the remote control to turn on the sensor/lights. Do you ever want to turn OFF the sensor and lights?

I don't necessarily want to turn it off, I'm just focusing on how to get the sensor to constantly self refresh it's value went it's turned on.

wape:
I don't necessarily want to turn it off, I'm just focusing on how to get the sensor to constantly self refresh it's value went it's turned on.

Declare a boolean variable and set it to true when the correct code is received.
Take readings when the boolean is true.

Your sketch is written:

void loop() {
  if (irrecv.decode(&results)) {
    //  Do all the stuff
  }
}

That means that NOTHING is done except for the instants when a IR code arrives. Your LDR only gets checked in that instant.

What you want is more like:

boolean DoStuff = false;
void loop() {
  if (irrecv.decode(&results)) {
    if (results.value == 0xFF30CF) { //activates code when this signal is received
        DoStuff = true;
    irrecv.resume(); //After receiving, this must be called to reset the receiver and prepare it to receive another signal
}

if (DoStuff) {
    sensorValue = analogRead(sensorPin); //reads value of Photoresistor
      if (sensorValue < 600) { // if light shining on photoresistor red and yellow LED turn on
        digitalWrite(RedLED, HIGH);
        digitalWrite(GreenLED, LOW);
        digitalWrite(YellowLED, HIGH);
        sensorValue = analogRead(sensorPin); //reads value of Photoresistor
      }
      else { // if no light shining on photoresistor green led LED turn on
        digitalWrite(RedLED, LOW);
        digitalWrite(GreenLED, HIGH);
        digitalWrite(YellowLED, LOW);
        sensorValue = analogRead(sensorPin); //reads value of Photoresistor
      }
    }
  }
}

Thank you so much johnwasser & UKHeliBob that was exactly what I needed!! my circuit works exactly as intended now!