increasing and decreasing brightness of led with ldr in arduino
int ledpin = 9;int ldrpin = 1;
int value = 0;void setup()
{Serial.begin(9600);}
void loop()
{
value = analogRead(ldrpin);
value = constrain(value,400,500);
value = map(value,400,500,255,0); Serial.println(value);
analogWrite(ledpin, value); delay(200);
}