Created
January 23, 2018 09:55
-
-
Save elktros/e9c48c217bdbb1469b6c7126bbdf39b8 to your computer and use it in GitHub Desktop.
Arduino Code for Automatic Door Opener System using PIR Sensor.
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 in1 = 2; | |
int in2 = 3; | |
int sensor = 8; | |
int led = 13; | |
void setup() | |
{ | |
pinMode(in1, OUTPUT); | |
pinMode(in2, OUTPUT); | |
pinMode(sensor, INPUT); | |
pinMode(led, OUTPUT); | |
digitalWrite(in1,LOW); | |
digitalWrite(in2,LOW); | |
//digitalWrite(sensor,LOW); | |
digitalWrite(led,LOW); | |
while(millis()<13000) | |
{ | |
digitalWrite(led,HIGH); | |
delay(50); | |
digitalWrite(led,LOW); | |
delay(50); | |
} | |
digitalWrite(led,LOW); | |
digitalWrite(in1,LOW); | |
digitalWrite(in2,HIGH); | |
} | |
void loop() | |
{ | |
if(digitalRead(sensor)==HIGH) | |
{ | |
digitalWrite(in1,HIGH); | |
digitalWrite(in2,LOW); | |
digitalWrite(led,HIGH); | |
delay(2000); | |
digitalWrite(in1,LOW); | |
digitalWrite(in2,LOW); | |
digitalWrite(in1,LOW); | |
digitalWrite(in2,HIGH); | |
digitalWrite(led,LOW); | |
delay(2000); | |
digitalWrite(in1,LOW); | |
digitalWrite(in2,LOW); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my door is opening 3 times and aint closing ..wat may be the problem?