Werktags vor 14:00 Uhr bestellt = am selben Tag versendet 30 Tage Widerrufsrecht 1 Jahr Garantie
← Zurück zur Übersicht

Beim Abspielen wird das Video von YouTube geladen.

Schaltplan und Codebeispiel

So schließt du den Mini PIR pyroelektrischer Infrarot-Bewegungssensor an einen Arduino UNO oder ESP32 an, mit einem Beispiel-Sketch, den du direkt hochladen kannst.

Mini-PIR-Bewegungsmelder

Dieses Projekt erkennt Bewegungen mit einem Mini-PIR-Sensor und schaltet die eingebaute LED des Arduino ein. Wenn eine Bewegung erkannt wird, leuchtet die LED auf und es wird eine Meldung im Serial Monitor ausgegeben. Gib dem Sensor nach dem Einschalten eine kurze Aufwärmzeit, damit er sich stabilisieren kann.

Anschlussplan: Mini PIR pyroelektrischer Infrarot-Bewegungssensor an einem Arduino UNO
Anschlussplan · Zum Vergrößern klicken
Anschlusstabelle: Mini PIR pyroelektrischer Infrarot-Bewegungssensor an einem Arduino UNO
Anschlusstabelle · Zum Vergrößern klicken
Mini_PIR_Motion_Detector.ino · kompiliert und getestet
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : Mini PIR Motion Detector
 *  Board     : Arduino UNO (arduino:avr:uno)
 *  Parts     : Mini PIR
 *  Libraries : none (built-in)
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

// Pin definitions
const int pirPin = 2;
const int ledPin = 13;

void setup() {
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  
  Serial.begin(115200);
  Serial.println(F("Mini PIR Sensor Initializing..."));
  Serial.println(F("Waiting 5 seconds for sensor to settle..."));
  delay(5000);
  Serial.println(F("Ready! Monitoring for motion..."));
}

void loop() {
  int motionDetected = digitalRead(pirPin);

  if (motionDetected == HIGH) {
    digitalWrite(ledPin, HIGH);
    Serial.println(F("Motion detected!"));
  } else {
    digitalWrite(ledPin, LOW);
    Serial.println(F("Scanning... No motion."));
  }

  delay(300);
}

Wiring diagram and example code generated by Codey.online — https://www.codey.online

Mini PIR-Bewegungsmelder mit ESP32

Dieses Projekt erkennt menschliche Bewegung mit einem Mini PIR-Bewegungssensor. Wenn eine Bewegung erkannt wird, schaltet der ESP32 die onboard LED (GPIO 2) ein und gibt eine Meldung im Serial Monitor aus. Die Versorgung des Sensors mit 3.3V sorgt für sichere Signalpegel für den ESP32-Eingang.

Anschlussplan: Mini PIR pyroelektrischer Infrarot-Bewegungssensor an einem ESP32 DevKit V1
Anschlussplan · Zum Vergrößern klicken
Anschlusstabelle: Mini PIR pyroelektrischer Infrarot-Bewegungssensor an einem ESP32 DevKit V1
Anschlusstabelle · Zum Vergrößern klicken
Mini_PIR_Motion_Detector_with_ESP32.ino · kompiliert und getestet
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : Mini PIR Motion Detector with ESP32
 *  Board     : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
 *  Parts     : Mini PIR
 *  Libraries : none (built-in)
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

// Mini PIR Motion Detection with ESP32

const int PIR_PIN = 13;     // Connected to Mini PIR OUT
const int LED_PIN = 2;      // ESP32 onboard LED

int lastState = LOW;

void setup() {
  Serial.begin(115200);
  pinMode(PIR_PIN, INPUT);
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, LOW);

  Serial.println("PIR Sensor Initializing... Please wait 10-30s for sensor warm-up.");
}

void loop() {
  int currentState = digitalRead(PIR_PIN);

  if (currentState != lastState) {
    lastState = currentState;
    if (currentState == HIGH) {
      digitalWrite(LED_PIN, HIGH);
      Serial.println("Motion detected!");
    } else {
      digitalWrite(LED_PIN, LOW);
      Serial.println("Motion ended.");
    }
  }

  delay(50);
}

Wiring diagram and example code generated by Codey.online — https://www.codey.online