Arduino Uno Program If statement Issue (comparator)

Hi Guys,

I'm trying to implement a simple code which reads from a LDR1 and depending on its analog value or Voltage Equivalent value. It will light and LED attached to pin 13. The biggest statement being the If statement. When i test the program even though the LDR1 Value is greater than 4.0 it still light up the LED and even when LDR1 Value is <4.0 it still lights up. It only lights up for a second and doesn't hold. Does anyone know why my If statement is not working as i expect it to be?

#include <SPI.h>
#include <SD.h>

const int chipSelect = 4;
Sd2Card card;
SdVolume volume;
SdFile root;
void setup() {
  Serial.begin(9600);
  Serial.println("initializing SD Card...");
  if (!SD.begin(chipSelect)){
    Serial.println("Card Failed, or not Present");
    return;
  }
pinMode (13,OUTPUT);
}


void loop() {
  // put your main code here, to run repeatedly:

int Three = analogRead(A0);
Serial.print("3VA1: ");
Serial.print(Three);
float Three1 = Three*(3.3/683);
Serial.print("      ");
Serial.print("3.3 Volt =");
Serial.print(Three1);

int Five = analogRead(A1);
Serial.println("");
Serial.print("5VAO: ");
Serial.print(Five);
float Five1= Five* (5.0/1023.0);
Serial.print("      ");
Serial.print("  5 Volt =");
Serial.println(Five1);

float LDR = analogRead(A2);

Serial.print("");
Serial.print("LDRA2: ");
Serial.print(LDR);
float LDR1= LDR* (5.0/835.0);
Serial.print("      ");
Serial.print("  LDR Volt =");
Serial.println(LDR1);
Serial.println("");
if (LDR1 > 4.0){
     digitalWrite(13,HIGH);
  }
  else{
  digitalWrite(13,LOW);
  }


String dataString = String(Three1) + "," + String(Five1) + "," + String(LDR1);
File Voltage = SD.open("Volu.TXT", FILE_WRITE);
if (Voltage){
  Voltage.print("3.3Volts = ");
  Voltage.print(Three1);
  Voltage.print(" , ");
  Voltage.print("5Volts = ");
  Voltage.println(Five1); 
  Voltage.print(" , ");
  Voltage.print("LDR Volts = ");
  Voltage.println(LDR1);
  Voltage.close();
  Serial.println("Sucessful Log");
  delay(2000);  

}
else {
  Serial.println("error opening voltage.txt");
}
delay(1000);
}

im guess you are using a uno.

if so pin 13 is in use by spi.h I think

SD card readers are communicated with using SPI. Do not use the SPI pins for ANY other purpose.

Pin D13 is SCK. It will light up while you are communicating with the SD card. Choose another pin (you'll have to supply your own LED, and current-limiting resistor).