sensor-experiments

Contact Us

If you have any questions or inquiries, feel free to reach out to us at Microautomation.no@icloud.com .

Follow our Socials for the newest updates!

Introduction

Learn how to build a basic motion detector using a Passive Infrared (PIR) sensor. When motion is detected, the Arduino triggers an LED to light up as an alert.

Required Components

No Ads Available.

Wiring Diagram

Follow this wiring setup:

Arduino Code


#include 

const int pirPin = 2;    // PIR sensor output pin
const int ledPin = 13;   // LED pin

void setup() {
    pinMode(pirPin, INPUT);
    pinMode(ledPin, OUTPUT);
    Serial.begin(9600);
}

void loop() {
    int motion = digitalRead(pirPin);
    if (motion == HIGH) {
        digitalWrite(ledPin, HIGH);  // Turn on LED
        Serial.println("Motion detected!");
    } else {
        digitalWrite(ledPin, LOW);   // Turn off LED
    }
    delay(100);
}
            

Applications

Conclusion

By following this tutorial, you can use a PIR sensor to create motion detection systems for various projects. Try experimenting with adding sound or notifications!

Contact Us

If you have any questions or inquiries, feel free to reach out to us at Microautomation.no@icloud.com .

Follow our Socials for the newest updates!