const int piezoPin = A0; // Analog pin for the piezo sensor
const int buzzerPin = 9; // Pin for the active buzzer
// Vibration threshold (adjust based on testing)
const int threshold = 250;
// Alarm duration in milliseconds
const int alarmDuration = 1000;
void setup() {
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600); // Begin serial communication for debugging
}
void loop() {
int piezoValue = analogRead(piezoPin);
Serial.println(piezoValue); // Debug: print sensor reading
if (piezoValue > threshold) {
triggerAlarm();
}
delay(100); // Prevent serial flooding
}
void triggerAlarm() {
digitalWrite(buzzerPin, HIGH);
delay(alarmDuration);
digitalWrite(buzzerPin, LOW);
}
Notes:
Choosing a selection results in a full page refresh.
Press the space key then arrow keys to make a selection.
Use left/right arrows to navigate the slideshow or swipe left/right if using a mobile device