SKU: OT704-C87 Numer artykułu: AB039 EAN: 8029313760373
Czujnik ruchu PIR HC-SR501 to podczerwony czujnik ruchu o następujących parametrach:
– Zasięg detekcji: 3-7m.
– Opóźnienie: 5-200s
– Napięcie wyjściowe: 3.3V
- Zasilanie: 4.5-20V
– Kąt detekcji: <140°.
Czujnik ruchu PIR HC-SR501 na podczerwień wykrywa ruch. Gdy ruch zostanie wykryty, na pinie wyjściowym pojawia się sygnał 3.3v, a czas jest regulowany potencjometrem VR1. Zasięg detekcji można regulować w zakresie 3-7 metrów za pomocą potencjometru VR2.
Tak podłączysz Czujnik PIR HC-SR501 czujnik ruchu do Arduino UNO lub ESP32, z przykładowym szkicem, który możesz od razu wgrać.
Ten projekt wykrywa ruch człowieka za pomocą czujnika PIR HC-SR501. Gdy ruch zostanie wykryty, pin wyjściowy czujnika przechodzi w stan HIGH, zapalając onboard LED i wyświetlając alert w Serial Monitor. Otwórz Serial Monitor z prędkością 115200 baud, aby obserwować stan ruchu w czasie rzeczywistym.
/*
* ==================================================================
* Generated by Codey.online — https://www.codey.online
* ==================================================================
* Project : HC-SR501 Motion Detection with Arduino Uno
* Board : Arduino UNO (arduino:avr:uno)
* Parts : HC-SR501 PIR Motion Sensor
* 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.
* ==================================================================
*/
// HC-SR501 PIR Motion Sensor Demo
const int PIR_PIN = 2;
const int LED_PIN = 13;
int lastState = LOW;
void setup() {
pinMode(PIR_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
Serial.begin(115200);
Serial.println(F("HC-SR501 PIR Motion Sensor Initialized"));
Serial.println(F("Warming up sensor (approx. 30-60 seconds)..."));
}
void loop() {
int motionState = digitalRead(PIR_PIN);
if (motionState != lastState) {
if (motionState == HIGH) {
digitalWrite(LED_PIN, HIGH);
Serial.println(F("Motion detected!"));
} else {
digitalWrite(LED_PIN, LOW);
Serial.println(F("Motion ended."));
}
lastState = motionState;
}
delay(100);
}
Wiring diagram and example code generated by Codey.online — https://www.codey.online
Ten projekt wykrywa ruch za pomocą czujnika PIR HC-SR501. Czujnik jest zasilany z pinu 5V VIN, a dzielnik napięcia z rezystorów 1kΩ/2kΩ bezpiecznie łączy wyjście czujnika z wejściem 3.3V ESP32. Gdy ruch zostanie wykryty, onboard LED zapala się, a powiadomienie jest wysyłane do Serial Monitor.
/*
* ==================================================================
* Generated by Codey.online — https://www.codey.online
* ==================================================================
* Project : Motion Detection with HC-SR501 and ESP32
* Board : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
* Parts : HC-SR501 PIR Motion Sensor
* 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.
* ==================================================================
*/
// HC-SR501 PIR Motion Sensor Demo
const int PIR_PIN = 13; // Connected to HC-SR501 OUT via divider
const int LED_PIN = 2; // Onboard LED
int lastState = LOW;
void setup() {
Serial.begin(115200);
pinMode(PIR_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
Serial.println("HC-SR501 Sensor warming up (approx. 30-60s)...");
delay(2000);
Serial.println("Ready to detect motion.");
}
void loop() {
int motion = digitalRead(PIR_PIN);
if (motion != lastState) {
if (motion == HIGH) {
digitalWrite(LED_PIN, HIGH);
Serial.println("Motion detected!");
} else {
digitalWrite(LED_PIN, LOW);
Serial.println("Motion ended.");
}
lastState = motion;
}
delay(50);
}
Wiring diagram and example code generated by Codey.online — https://www.codey.online