Last active
October 11, 2018 10:34
-
-
Save elktros/bc02bbe50732191438ebad55c88f792a to your computer and use it in GitHub Desktop.
Arduino Code for Automatic Room Lights using Arduino and PIR Sensor 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 in1 = 9; | |
int sensor = 8; | |
int led = 13; | |
unsigned long t=0; | |
void setup() | |
{ | |
Serial.begin(9600); | |
pinMode(in1, OUTPUT); | |
pinMode(sensor, INPUT); | |
pinMode(led, OUTPUT); | |
digitalWrite(in1,HIGH); | |
digitalWrite(led,LOW); | |
while(millis()<13000) | |
{ | |
digitalWrite(led,HIGH); | |
delay(50); | |
digitalWrite(led,LOW); | |
delay(50); | |
} | |
digitalWrite(led,LOW); | |
} | |
void loop() | |
{ | |
digitalWrite(in1,HIGH); | |
digitalWrite(led,LOW); | |
if(digitalRead(sensor)==HIGH) | |
{ | |
t=millis(); | |
while(millis()<(t+5000)) | |
{ | |
digitalWrite(in1,LOW); | |
digitalWrite(led,HIGH); | |
if((millis()>(t+2300))&&(digitalRead(sensor)==HIGH)) | |
{ | |
t=millis(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is this code 100% correct