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

Arduino UNO Motion Detector with PIR Sensor and LED Indicator

View and Edit Project In Cirkit DesignerImage of Arduino UNO Motion Detector with PIR Sensor and LED Indicator

Circuit Documentation

Summary

This document describes a motion detector system using an Arduino UNO, a PIR sensor, and a red LED. The system is designed to turn on the LED when motion is detected by the PIR sensor.

Component List

Arduino UNO

PIR Sensor

LED: Two Pin (red)

Wiring Details

Arduino UNO

PIR Sensor

LED: Two Pin (red)

Code

/*
 * This Arduino sketch is designed to create a motion detector system using a
 * PIR sensor and an LED. When motion is detected by the PIR sensor, the LED
 * will turn on automatically.
 */

// Define pin connections
const int pirPin = 3; // PIR sensor signal pin connected to D3
const int ledPin = 2; // LED anode pin connected to D2

void setup() {
  // Initialize the PIR sensor pin as an input
  pinMode(pirPin, INPUT);
  // Initialize the LED pin as an output
  pinMode(ledPin, OUTPUT);
  // Start with the LED off
  digitalWrite(ledPin, LOW);
}

void loop() {
  // Read the PIR sensor value
  int pirValue = digitalRead(pirPin);
  // If motion is detected, turn on the LED
  if (pirValue == HIGH) {
    digitalWrite(ledPin, HIGH);
  } else {
    // If no motion is detected, turn off the LED
    digitalWrite(ledPin, LOW);
  }
  // Small delay to avoid bouncing
  delay(100);
}

This code initializes the PIR sensor and LED pins, reads the PIR sensor value, and turns the LED on or off based on the sensor's input. The LED will light up when motion is detected and turn off when no motion is detected.