Codey OnlineBiblioteka komponentów Arduino i ESP32 › PIR Sensor HC-SR501
PIR Sensor HC-SR501
Czujniki

PIR Sensor HC-SR501

Czujnik PIR HC-SR501 wykrywa zmiany promieniowania podczerwonego (IR) wywołane ruchem, zwykle ludzi lub zwierząt. Udostępnia cyfrowy sygnał wyjściowy (OUT), który można bezpośrednio odczytać za pomocą mikrokontrolerów takich jak Arduino lub ESP32, korzystając ze standardowych pinów zasilania i masy (VCC i GND).

Szerokość: 33.1 mm

Pinout — PIR Sensor HC-SR501

Pin Sygnał Opis
GND GND Ground
OUT digital out
VCC VCC Power positive

Przykładowy schemat połączeń — PIR Sensor HC-SR501

Z Do Przewód
board:5V x1:VCC red
board:GND x1:GND black
board:D2 x1:OUT green

Przykładowy kod Arduino — PIR Sensor HC-SR501

Ten przykład został napisany i sprawdzony kompilacją dla arduino-uno. Codey Online dostosuje go do każdej innej obsługiwanej płytki.

// PIR Sensor HC-SR501 - canonical beginner example
// Reads the sensor output on D2 and prints motion status to Serial Monitor.

const int pirPin = 2;

void setup() {
  pinMode(pirPin, INPUT);
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
  Serial.println("PIR sensor warming up... give it about 30-60 seconds.");
}

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

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

  delay(500);
}

Podobne komponenty

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

Zbuduj swój projekt Arduino lub ESP32 z pomocą AI

Opisz, co chcesz zbudować. Codey Online napisze kod, narysuje schemat połączeń, skompiluje projekt i wgra go na płytkę bezpośrednio z przeglądarki.

Zacznij za darmo