Codey OnlineBibliothèque de composants Arduino & ESP32 › HC-SR501 PIR Motion Sensor
HC-SR501 PIR Motion Sensor
Capteurs

HC-SR501 PIR Motion Sensor

Module de capteur de mouvement PIR infrarouge HC-SR501 pour Arduino et

Largeur: 42.3 mm

Brochage — HC-SR501 PIR Motion Sensor

Broche Signal Description
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.

Exemple de schéma de câblage — HC-SR501 PIR Motion Sensor

De Vers Fil
board:5V x1:VCC red
board:GND x1:GND black
board:D2 x1:OUT green

Exemple de code Arduino — HC-SR501 PIR Motion Sensor

Cet exemple a été écrit et vérifié à la compilation pour le arduino-uno. Codey Online l'adapte pour vous à toute autre carte prise en charge.

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

Composants similaires

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

Construisez votre projet Arduino ou ESP32 avec l'IA

Décrivez ce que vous voulez créer. Codey Online écrit le code, dessine le schéma de câblage, le compile et flashe votre carte directement depuis le navigateur.

Commencez gratuitement