Sanyam Chugh
Published

Motion Detector

If,u cn detect motion around ur surrounding nd then take decisions,it'lll be called a smart decision :)Lets learn,how to make smart decision

BeginnerShowcase (no instructions)1 hour21
Motion Detector

Code

Motion Detector

Arduino
This device will detect any motion around it and ,will glow LED ,whenever ,motion is detected
int sensor =2;
int sensor_value;

void setup() 
{
  pinMode(2,INPUT);
  pinMode(5,OUTPUT);
  Serial.begin(9600);
  pinMode(8,OUTPUT);
}
void loop()
{
  sensor_value=digitalRead(sensor);
  Serial.println(sensor_value);
  if(sensor_value==0)
  { 
   digitalWrite(5,HIGH);
   digitalWrite(8,LOW);

    }
  else if(sensor_value==1)
  {
    digitalWrite(8,HIGH);
    digitalWrite(5,LOW);
    

  }
 
  }

Credits

Sanyam Chugh
13 projects • 2 followers
Contact

Comments

Please log in or sign up to comment.