#define TOUCH_PIN T0 // GPIO4
#define BUZZER_PIN 18
void setup() {
Serial.begin(115200); // Initialize serial monitor
pinMode(BUZZER_PIN, OUTPUT); // Set buzzer as output
pinMode(TOUCH_PIN, INPUT_PULLUP); // Enable internal pull-up for the button
Serial.println("System Ready");
}
void loop() {
int buttonState = digitalRead(TOUCH_PIN); // Read button state
if (buttonState == LOW) { // Button pressed (simulate touch)
digitalWrite(BUZZER_PIN, HIGH); // Activate buzzer
Serial.println("ALARM! DOOR TOUCHED!");
delay(1000); // Keep alarm active for 1 second
digitalWrite(BUZZER_PIN, LOW); // Turn off buzzer
}
delay(100); // Small delay for stability
}