int buzzerPin = 7; // define the buzzer pin
int wirePin = 2; // define the wire pin
void setup() {
pinMode(buzzerPin, OUTPUT);
pinMode(wirePin, INPUT);
Serial.begin(9600);
}
void loop() {
if (digitalRead(wirePin) == HIGH) { // if loop touches the wire
digitalWrite(buzzerPin, HIGH); // turn on the buzzer
delay(500); // wait for 500ms
digitalWrite(buzzerPin, LOW); // turn off the buzzer
}
}