const int ledPin = 9; //the number of the LED pin
const int ldrPin = A0; //the number of the LDR pin
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT); //initialize the LED pin as an output
pinMode(ldrPin, INPUT); //initialize the LDR pin as an input
}
void loop() {
int ldrValue = analogRead(ldrPin); // Read the LDR value
Serial.println(ldrValue); // Print the LDR value for debugging
int pwmValue0 = map(ldrValue, 0, 1023, 0, 255);
// int pwmValue1 = 255 - pwmValue0; // Inverse the PWM value for the second LED
analogWrite(ledPin, pwmValue0); // Set the PWM value for the first LED
delay(100);
}