SKU: OT704-C87 Numéro d’article: AB039 EAN: 8029313760373
Le capteur de mouvement PIR HC-SR501 est un capteur de mouvement infrarouge avec les spécifications suivantes :
– Distance de détection : 3-7 m.
– Temporisation : 5-200 s
– Tension de sortie : 3.3V
- Fonctionne avec : 4.5-20V
– Angle de détection : <140°.
Le capteur de mouvement PIR HC-SR501 détecte les mouvements infrarouges PIR. Lorsqu’un mouvement est détecté, il fournit un signal de 3.3V sur la broche de sortie ; la durée est réglable via le potentiomètre VR1. La distance de détection est réglable de 3 à 7 mètres via le potentiomètre VR2.
Voici comment connecter le Capteur PIR HC-SR501 capteur de mouvement à un Arduino UNO ou à un ESP32, avec un exemple de sketch que tu peux téléverser directement.
Ce projet détecte les mouvements humains à l'aide du capteur PIR HC-SR501. Lorsqu'un mouvement est détecté, la broche de sortie du capteur passe à HIGH, ce qui allume la LED intégrée et affiche une alerte dans le Serial Monitor. Ouvrez le Serial Monitor à 115200 baud pour voir l'état du mouvement en temps réel.
/*
* ==================================================================
* 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
Ce projet détecte les mouvements à l'aide d'un capteur PIR HC-SR501. Le capteur est alimenté depuis la broche 5V VIN, et un diviseur de tension avec une résistance de 1kΩ/2kΩ permet d'adapter en toute sécurité la sortie du capteur à l'entrée 3.3V de l'ESP32. Lorsqu'un mouvement est détecté, la LED intégrée s'allume et une notification est envoyée au 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