const int ldrPins[] = {A0, A1, A2}; // Array of LDR sensor pins
const int ledPins[] = {8, 9, 10}; // Array of LED pins
void setup() {
Serial.begin(9600);
for (int i = 0; i < 3; i++) {
pinMode(ldrPins[i], INPUT);
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
for (int i = 0; i < 3; i++) {
// Read analog value from LDR
int lightIntensity = analogRead(ldrPins[i]);
// Map the analog value to a range suitable for LED control
int brightness = map(lightIntensity, 0, 1023, 0, 255);
// Turn on/off the corresponding LED based on light intensity
if (brightness > 150) {
digitalWrite(ledPins[i], HIGH); // Turn on LED
} else {
digitalWrite(ledPins[i], LOW); // Turn off LED
}
// Print light intensity to the serial monitor
Serial.print("LDR ");
Serial.print(i + 1);
Serial.print(": ");
Serial.println(lightIntensity);
delay(100); // Adjust the delay as needed
}
}