Created
February 17, 2018 04:18
-
-
Save elktros/dbb8ad8eb2bddc9ca2d71424fb652b7f to your computer and use it in GitHub Desktop.
Code for Arduino PIR Sensor Tutorial Project.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int buzzer = 11; | |
int sensor = 8; | |
int led = 13; | |
void setup() | |
{ | |
pinMode(buzzer, OUTPUT); | |
pinMode(sensor, INPUT); | |
pinMode(led, OUTPUT); | |
digitalWrite(buzzer,LOW); | |
digitalWrite(sensor,LOW); | |
digitalWrite(led,LOW); | |
while(millis()<13000) | |
{ | |
digitalWrite(led,HIGH); | |
delay(50); | |
digitalWrite(led,LOW); | |
delay(50); | |
} | |
digitalWrite(led,HIGH); | |
} | |
void loop() | |
{ | |
if(digitalRead(sensor)==HIGH) | |
{ | |
digitalWrite(buzzer,HIGH); | |
delay(3000); | |
digitalWrite(buzzer,LOW); | |
while(digitalRead(sensor)==HIGH); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment