Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Controlled Servo with PIR Motion Detection

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Servo with PIR Motion Detection

Circuit Documentation

Summary

This circuit is designed to interface an Arduino UNO with a Servomotor SG90 and a PIR (Passive Infrared) Motion Sensor. The Arduino UNO is powered by a 9V battery and controls the servomotor based on the input from the PIR sensor. When motion is detected by the PIR sensor, the Arduino UNO commands the servomotor to rotate to a specified angle. The circuit is intended for applications where motion detection is required to trigger a mechanical response, such as in automated doors, alarms, or interactive installations.

Component List

Arduino UNO

Servomotor SG90

PIR/Motion Sensor

Battery 9V

Wiring Details

Arduino UNO

Servomotor SG90

PIR/Motion Sensor

Battery 9V

Documented Code

#include <Servo.h>
Servo myservo;

int pir = 7;  // digital pin for PIR motion sensor

void setup()
{
  pinMode(pir, INPUT);
  myservo.attach(8);  // digital pin for servo motor
  Serial.begin(9600);
}

void loop()
{
  int x = digitalRead(pir);
  Serial.println(x);
  
  if(x == HIGH)
  {
    myservo.write(180);  // move servo to 180 degrees
    delay(3000);         // wait for 3 seconds
  }
  else
  {
    myservo.write(0);    // move servo back to 0 degrees
  }
}

Code Explanation