Answers for "increasing and decreasing brightness of led with ldr in arduino"

0

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);
}
Posted by: Guest on June-27-2021

Browse Popular Code Answers by Language