Codey OnlineBiblioteca de componentes Arduino y ESP32 › HC-SR501 PIR Motion Sensor
HC-SR501 PIR Motion Sensor
Sensores

HC-SR501 PIR Motion Sensor

Módulo sensor de movimiento PIR infrarrojo HC-SR501 para Arduino y

Ancho: 42.3 mm

Pinout — HC-SR501 PIR Motion Sensor

Pin Señal Descripción
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.

Esquema de cableado de ejemplo — HC-SR501 PIR Motion Sensor

Desde Hasta Cable
board:5V x1:VCC red
board:GND x1:GND black
board:D2 x1:OUT green

Código Arduino de ejemplo — HC-SR501 PIR Motion Sensor

Este ejemplo se escribió y verificó por compilación para arduino-uno. Codey Online lo adapta a cualquier otra placa compatible.

// 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);
}

Componentes relacionados

18650 Battery Shield with USB-C Charger and 5V Boost Converter

18650 Battery Shield with USB-C Charger and 5V Boost Converter

2.4 inch OLED Display I2C 3.3V

2.4 inch OLED Display I2C 3.3V

3.5 inch TFT LCD Shield

3.5 inch TFT LCD Shield

50kg Load Cell Weight Sensor

50kg Load Cell Weight Sensor

Crea tu proyecto de Arduino o ESP32 con IA

Describe lo que quieres construir. Codey Online escribe el codigo, dibuja el esquema de conexiones, lo compila y graba tu placa directamente desde el navegador.

Empieza gratis