Skip to content

Instantly share code, notes, and snippets.

@atifahsuad
Created August 23, 2018 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atifahsuad/619e062e602e6a17b0e112af461a94ec to your computer and use it in GitHub Desktop.
Save atifahsuad/619e062e602e6a17b0e112af461a94ec to your computer and use it in GitHub Desktop.
This sample code is for Detecting People Using PIR Sensor's Tutorial by Cytron Technologies Sdn. Bhd.
/*
This example code is for Detecting People with PIR Motion Sensor.
Product page:
Maker UNO: https://www.cytron.io/p-maker-uno
PIR Sensor : https://www.cytron.io/p-sn-pir
Created by:
23/08/18 Suad Anwar, Cytron Technologies
*/
int Buzzer = 8; // choose the pin for the LED
int PIRpin = 5; // choose the input pin (for PIR sensor)
int PIRstate = 0; // we start, assuming no motion detected
void setup() {
pinMode(Buzzer, OUTPUT); // initialize the LED pin as an output:
pinMode(PIRpin, INPUT); // initialize the PIR sensor pin as an input:
}
void loop() {
PIRstate = digitalRead(PIRpin); // read the state of the pushbutton value:
// check if the PIR sensor is triggered. If it is, the PIRstate is HIGH:
if (PIRstate == HIGH) {
tone(Buzzer, 494, 700);
delay(900);
tone(Buzzer, 392, 900);
delay(1300);
} else {
noTone;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment