/*
Three zone light sensor
April 15, 2026
*/
const int NUM_ZONES = 3;
const int PIR_PIN = 12;
const int LED_PINS[] = {6, 5, 3};
const int SENSE_PINS[] = {A2, A1, A0};
void setup() {
Serial.begin(115200);
pinMode(PIR_PIN, INPUT);
for (int i = 0; i < NUM_ZONES; i++) {
pinMode(LED_PINS[i], OUTPUT);
}
}
void loop() {
if (digitalRead(PIR_PIN)) {
int lightValues[NUM_ZONES];
for (int i = 0; i < NUM_ZONES; i++) {
lightValues[i] = map(analogRead(SENSE_PINS[i]), 1023, 0, 0, 255);
analogWrite(LED_PINS[i], lightValues[i]);
}
}
}