Introduction: Control Servo Using PIR Sensor
Hi guys, I'm Sridhar janardhan popularly known as Appytechie.I feel privileged to share my first instructables.In today's instructables i am going to deal with the control of servo using a PIR sensor.Where can we implement this idea ?? imagine the working of automatic doors, it required laser light technology sometimes which might be expensive, So to come up with the same function in an affordable cost we have found this circuit that consists of three component and a little bit of coding experience.
So let's get started.
Step 1: Components Required :
The components required for this Instructables are :-
- Arduino Uno
- PIR sensor
- Servo motor
- Breadboard
- Jumper wire
So after gathering the required component let's get into building the circuit.
Step 2: Connecting the Sensor :
Passive Infrared Sensor (PIR) , a sensor that measures infrared light radiating from objects in field. The sensor work upon the temperature changes in the field of its radiation. For example, if a human passes by its field the temperature changes from room temperature to the body temperature this change in temperature is sent as a signal to the Arduino board.
Connection of the PIR sensor to the Arduino board is as follows :-
- VCC to the positive railings of the Bread board.
- OUT pin to the Digital pin 12 of the Arduino board.
- GND pin to the Negative railings of the Bread board.
After implementing the connection of the PIR sensor let's connect the servo motor.
Step 3: Servo Connection :
Servo motors, A specially designed motor to control the angular positions.It has three wires coming out of its case i.e Signal wire(Orange wire), VCC wire(Usually red) and ground wire (Usually black or even maroon ).
The Servo are connected to the Arduino as follows:
- Signal wire (Orange wire) is connected to the digital pin 4.
- VCC wire (red wire) is connected to the positive railings of Breadboard.
- GND wire is connected to the Negative railings of the breadboard.
So before we upload the code into the Arduino make sure we connect the 5v pin on the Arduino to positive railings of the Breadboard and the GND pin of Arduino to the negative railings of the Breadboard.
Step 4: The Output :
Step 5: Leave a Comment Below :
If any of the users are feeling difficult in above project or you need an assistance in any of your electronics project please feel free to leave a comment below.
Mail me the project name in which you need assistance at official.appytechie@gmail.com.

Participated in the
Makerspace Contest 2017
17 Comments
Question 4 years ago
Hi good day, im Arjay a college student.
I just want to ask for a help regarding my project "Automated Door using Pir and Servo(DOOR) like the one on the entrance of malls but in cheaper and miniature version.
I just want to ask for your help in coding.
The scenario is, when the PIR SENSOR detects motion, the door opens BUT it closes after 5 seconds(5 seconds was based on the adjustment I've done on the Time Delay trimmer of the PIR).
Now, the condition is, when the PIR detects someone and he/she is staying at the opening of the door, the door should remain open.
Can you please help me figure out the logic behind that automated door? where as long as im staying in the front of the door, the servo/door SHOULD still remain open and it only CLOSES when i walk pass the door or no any other motion is detected.
Please
This is my code and i know im missing some logic in this. I hope for your response, and any advice would be a big big big help to me. Thank you and godbless!
#include <Servo.h> // Library for Servo
Servo myservo; // Name of my Servo
int led = 13;
int sensor = 2; // Sensor is connected to D2
int state = LOW; // Initial value for variable state is low
int val = 0; // Initial value for variable val is 0
void setup() {
pinMode(led, OUTPUT);
myservo.attach(9); // Servo is connected to D9
pinMode(sensor, INPUT); // D2 is set as a Input
Serial.begin(9600); // Start for Serial Communication
}
void loop() {
val = digitalRead(sensor);
if(val==HIGH){
digitalWrite(led, HIGH);
myservo.write(60);
if (state == LOW){
Serial.println("Motion Detected");
state = HIGH;
}
}
else {
digitalWrite(led, LOW);
myservo.write(180);
if(state == HIGH){
Serial.println("Motion Stopped");
state = LOW;
}
}
delay(10);
Answer 1 year ago
Where is the code?
Answer 2 years ago
Thank you bro for the code
Question 3 years ago
Where is the code?
Question 4 years ago on Step 4
Where is the code...?
4 years ago
Hi good day, im Arjay a college student.
I just want to ask for a help regarding my project "Automated Door using Pir and Servo(DOOR) like the one on the entrance of malls but in cheaper and miniature version.
I just want to ask for your help in coding.
The scenario is, when the PIR SENSOR detects motion, the door opens BUT it closes after 5 seconds(5 seconds was based on the adjustment I've done on the Time Delay trimmer of the PIR).
Now, the condition is, when the PIR detects someone and he/she is staying at the opening of the door, the door should remain open.
Can you please help me figure out the logic behind that automated door? where as long as im staying in the front of the door, the servo/door SHOULD still remain open and it only CLOSES when i walk pass the door or no any other motion is detected.
Please
This is my code and i know im missing some logic in this. I hope for your response, and any advice would be a big big big help to me. Thank you and godbless!
#include <Servo.h> // Library for Servo
Servo myservo; // Name of my Servo
int led = 13;
int sensor = 2; // Sensor is connected to D2
int state = LOW; // Initial value for variable state is low
int val = 0; // Initial value for variable val is 0
void setup() {
pinMode(led, OUTPUT);
myservo.attach(9); // Servo is connected to D9
pinMode(sensor, INPUT); // D2 is set as a Input
Serial.begin(9600); // Start for Serial Communication
}
void loop() {
val = digitalRead(sensor);
if(val==HIGH){
digitalWrite(led, HIGH);
myservo.write(60);
if (state == LOW){
Serial.println("Motion Detected");
state = HIGH;
}
}
else {
digitalWrite(led, LOW);
myservo.write(180);
if(state == HIGH){
Serial.println("Motion Stopped");
state = LOW;
}
}
delay(10);
4 years ago on Step 5
Please share the code i need it
Question 4 years ago
Nada adianta sem Código
not código?
Question 4 years ago
Código?
5 years ago
That looks good, thanks for sharing :)
Reply 4 years ago
Can you please share the codes with me at: nurkhanjuhoor123@gmail.com
Question 5 years ago
Would it be possible to email the code to sleal@houstonisd.org?
5 years ago
Looks great until you realize there's no code. Very annoying.
Question 5 years ago on Step 3
What code?
5 years ago
Where is the code man, upload the code, send it pkompally@gmail.com
Please urgent
5 years ago
Where is the code?
5 years ago
This is not the code for controlling servo