int buzzerPin = 15; // choose the pin for the button int inputPin = 3; // choose the input pin (for PIR sensor) int pirState = LOW; // we start, assuming no motion detected int val = 0; // variable for reading the pin status void setup() { pinMode(buzzerPin, OUTPUT); // declare button as output pinMode(inputPin, INPUT); // declare sensor as input Serial.begin(9600); } void loop(){ val = analogRead(inputPin); // read input value Serial.println(val); if (val >300) { // check if the input is HIGH tone(buzzerPin, 800); delay(2000); } else if (val > 350){ // val == higher tone(buzzerPin, 1000); // Send 1KHz sound signal... delay(1000); } else { tone(buzzerPin,100); delay(50); tone(buzzerPin,0); delay(200); } }