IF ELSE PROBLEM HELP

Hello friends. I bought a new arduino 5 days ago. I also apologize for my bad English.

When I use the '' IF '' command, I want the army to turn on the LED light.

For example, if your LDR value is greater than 500 denier, open the arduino light.

I try to work for it, but I have not been successful somehow. I apologize again for bad english. Have a good evening.

Also Im soo new about use Arduino.

int LDR=A0;
int LED=10;

void setup() {
  Serial.begin(9600);
  pinMode(10,OUTPUT);
  
  // put your setup code here, to run once:

}

void loop() {
  int LDRRead=analogRead(LDR);
  Serial.println(LDRRead);
  delay(200);

  if (LDR<500) {digitalWrite(LED,HIGH);}
  // put your main code here, to run repeatedly:

}

Need to see your code.
HowToPostCode

I want the army to turn on the LED light.

Give the army a legal order.

Hey Bro I used the Translate ORDU = ARMY İN TURKİSH and the translate understood false. I wanted say ARDUNİO

When I posted my answer, you hadn't posted any code.
Now I can see your code.

What turns the LED off?
How is the LED wired?

Here's what I recommend to do for the led. One check and mixture your positive and negative leads are correct to the led the longer one being positive and the shorter one being negative. In addition do digitalWrite(10, HIGH); This will set the led as off(high is off, low, is on). To turn led on do the opposite digitalWrite(10, LOW); I hope this helps.

Hi eserler,

Actually, you test the value of the PIN (LDR = "A0") and not the measured value (LDRRead).

Try

if (LDRRead<500)

Moreover, if the IF condition is not respected, for the time behing, your code ask to "not change anything", so to stay HIGH. You have to ask to the pin to change by adding an "ELSE" condition to turn off the led (LED,LOW)

Méric.

In your if, you use LDR instead of LDRRead. LDR is A0 and A0 equals zero so the if always evaluates to true.

LDR is A0 and A0 equals zero

A0 is at least 14

Now it also turn off the LED

int LDR = A0;
int LED = 10;

void setup() {
  Serial.begin(9600);
  pinMode(LED, OUTPUT);
  pinMode(LDR, INPUT);
}

void loop() {
  int LDRRead = analogRead(LDR);
  Serial.println(LDRRead);
  delay(200);
  if (LDRRead > 500)
  {
    digitalWrite(LED, HIGH);
  }
  else
  {
    digitalWrite(LED, LOW);
  }
}

AWOL:
A0 is at least 14

OOPS