Rajat Naruka
Published

motion sensor

In this, motion sensor is used to detect motion using arduino. whenever it will detect motion, buzzer will be on.

IntermediateProtip14
motion sensor

Things used in this project

Hardware components

PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
ZX Distance and Gesture Sensor
SparkFun ZX Distance and Gesture Sensor
×1

Schematics

966KJ2Nt9nJnA4QrHQJ1.jpg

Code

Motion sensor

Java
int sensor=6;
int sensor_value;


void setup() {
  pinMode(5,OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(sensor,INPUT);
  Serial.begin(9600);

}

void loop() {
  sensor_value=digitalRead(sensor);
  if(sensor_value==0)
  {
    digitalWrite(4,HIGH);
   
  }
  else if(sensor_value==1)
 {
    digitalWrite(5,HIGH);
  }
  
  
  Serial.println(sensor_value);
}

Credits

Rajat Naruka

Rajat Naruka

8 projects • 1 follower

Comments