Codey Online › Libreria di componenti Arduino ed ESP32 › HC-SR501 PIR Motion Sensor
HC-SR501 PIR Motion Sensor
Sensori

HC-SR501 PIR Motion Sensor

Modulo sensore di movimento PIR a infrarossi HC-SR501 per Arduino e

Larghezza: 42.3 mm

Pinout — HC-SR501 PIR Motion Sensor

Pin Segnale Descrizione
VCC power Power input for the PIR module, typically 5V DC to the onboard regulator.
OUT digital Digital motion output; goes high when PIR motion is detected.
GND ground Ground reference for power and the OUT signal.

Schema di cablaggio di esempio — HC-SR501 PIR Motion Sensor

Da A Filo
board:5V x1:VCC red
board:GND x1:GND black
board:D2 x1:OUT green

Codice Arduino di esempio — HC-SR501 PIR Motion Sensor

Questo esempio è stato scritto e verificato in compilazione per arduino-uno. Codey Online lo adatta a qualsiasi altra scheda supportata.

// HC-SR501 PIR Motion Sensor
// Reads the PIR motion output and prints when motion is detected.

const int pirPin = 2;

void setup() {
  pinMode(pirPin, INPUT);
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
  Serial.println("HC-SR501 PIR motion sensor ready");
}

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

  if (motionState == HIGH) {
    Serial.println("Motion detected!");
  } else {
    Serial.println("No motion");
  }

  delay(500);
}

Componenti correlati

PIR Sensor HC-SR501

PIR Sensor HC-SR501

Motion sensor with microwave radar RCWL-051

Motion sensor with microwave radar RCWL-051

Mini PIR

Mini PIR

LDR Light Sensor Module

LDR Light Sensor Module

Crea il tuo progetto Arduino o ESP32 con l'AI

Descrivi cosa vuoi realizzare. Codey Online scrive il codice, disegna lo schema di collegamento, lo compila e programma la tua scheda direttamente dal browser.

Inizia gratis