int sensorPin = A0; // Define the analog pin for the LDR
int ledPin = 8; // Define the digital pin for the LED
int sensorValue = 0; // Variable to store the value from the sensor
void setup() {
pinMode(ledPin, OUTPUT); // Set pin 8 as an OUTPUT
Serial.begin(9600); // Initialize serial communication at 9600 bps
}
void loop() {
sensorValue = analogRead(sensorPin); // Read the value from the LDR
Serial.print("Sensor Value: ");
Serial.println(sensorValue); // Print the sensor value to the serial monitor
// Map the sensor value to a delay time (e.g., 100 - 1000 ms)
int delayTime = map(sensorValue, 0, 1023, 100, 1000);
Serial.print("Delay Time: ");
Serial.println(delayTime); // Print the delay time to the serial monitor
digitalWrite(ledPin, HIGH); // Turn the LED on
delay(delayTime); // Wait for the delay time
digitalWrite(ledPin, LOW); // Turn the LED off
delay(delayTime); // Wait for the delay time
}