// Define the pins for the door sensor and LEDs
const int doorSensorPin = 1; // Replace with the appropriate GPIO pin
const int greenLEDPin = 23; // Replace with the appropriate GPIO pin
const int redLEDPin = 22; // Replace with the appropriate GPIO pin
void setup() {
// Initialize the pins
pinMode(doorSensorPin, INPUT);
pinMode(greenLEDPin, OUTPUT);
pinMode(redLEDPin, OUTPUT);
}
void loop() {
// Read the state of the door sensor (HIGH or LOW)
int doorState = digitalRead(doorSensorPin);
// Check the door state and control the LEDs accordingly
if (doorState == HIGH) {
// Door is open
digitalWrite(greenLEDPin, HIGH); // Turn on green LED
digitalWrite(redLEDPin, LOW); // Turn off red LED
} else {
// Door is closed
digitalWrite(greenLEDPin, LOW); // Turn off green LED
digitalWrite(redLEDPin, HIGH); // Turn on red LED
}
}