int BEL = 13;
int PIR = 15;
int PIRstatus = 0;
void setup() {
// put your setup code here, to run once:
Serial1.begin(115200);
Serial1.println("Sensor Gerak Dengan Output Suara");
pinMode(PIR, INPUT);
pinMode(BEL, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
PIRstatus = digitalRead(PIR);
if(PIRstatus == HIGH){
digitalWrite(BEL, HIGH);
tone(BEL,1000);
Serial1.println("Ada gerakan !");
}else{
digitalWrite(BEL, LOW);
tone(BEL,0);
Serial1.println("Tidak ada gerakan");
}
delay(500);
}