#define ldr 4
#define led 13
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(ldr, INPUT);
pinMode(led, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
float ldrValue = analogRead(ldr);
float brightness = map(ldrValue, 0, 4095, 0, 255);
analogWrite(led, brightness);
}