int photocelPin=0;
int photocelReading;
int LEDpin=11;
int LEDbrightness;



int photocelPin = A0; // Define photocell pin
int photocelReading;
int LEDpin = 11; // Define LED pin
int LEDbrightness;

void setup() {
  // Initialize serial communication
  Serial.begin(9600);
}

void loop() {
  // Read the analog value from the photocell
  photocelReading = analogRead(photocelPin);

  // Print the photocell reading to the serial monitor
  Serial.print("Analog reading: ");
  Serial.println(photocelReading);

  // Invert the photocell reading
  photocelReading = 1023 - photocelReading;

  // Map the inverted reading to LED brightness range
  LEDbrightness = map(photocelReading, 0, 1023, 0, 255);

  // Set LED brightness using PWM
  analogWrite(LEDpin, LEDbrightness);

  // Delay for stability
  delay(100);
}

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

void loop() {
  // put your main code here, to run repeatedly:
 photocelReading=analogRead(photocelPin);

 Serial.print("Analog reading=");
 Serial.println(photocelReading);

 photocelReading = 10213- photocelReading;

LEDbrightness=map(photocelReading,0, 1023, 0, 255);

analogWrite(LEDpin,LEDbrigtness);

delay(100);

}