Increases the output high duration (up to ~200 seconds).
3.3V High / 0V Low (Safe for Arduino, ESP32, and Raspberry Pi).
| Pin Number | Pin Name | Description | | :--- | :--- | :--- | | 1 | | Power input (5V – 20V DC) | | 2 | OUT | Digital output: HIGH when motion detected, LOW when idle | | 3 | GND | Ground (0V) | hw-416-b pir sensor datasheet
Ground connection (Connect to the system common ground). Onboard Adjustments (Potentiometers)
void loop() motionState = digitalRead(motionPin); if (motionState == HIGH) digitalWrite(ledPin, HIGH); Serial.println("Motion detected!"); else digitalWrite(ledPin, LOW); Increases the output high duration (up to ~200 seconds)
The HW-416-B operates by detecting changes in infrared radiation emitted by moving objects (such as humans or animals). It integrates a pyroelectric sensor with an onboard control IC to deliver a simple digital output. Key Specifications
Digital output. High (3.3V) when motion is detected; Low (0V) when idle. GND: Ground connection. 3. Onboard Adjustments High (3
PIR sensors are highly sensitive to rapid environmental changes. Avoid mounting the HW-416-B directly facing windows, heating vents, air conditioners, or high-power incandescent lighting, as sudden shifts in air temperature can falsely trip the sensor.
At midnight she tested again. The lamp obeyed: soft amber glow filling the room when she passed, conserving power the rest of the night. She smiled at the neatness of it—the way the datasheet’s sterile tables had translated into a living thing that answered a human need. The HW-416-B had become more than numbers; it was a small sentinel that watched over sleep and returned the favor with light.
// Define Pins const int PIR_PIN = 2; // Connect the HW-416-B OUT pin here const int LED_PIN = 13; // Onboard Arduino LED // Variables to track sensor state int sensorState = LOW; int val = 0; void setup() pinMode(PIR_PIN, INPUT); // Declare PIR output as Input pinMode(LED_PIN, OUTPUT); // Declare onboard LED as Output Serial.begin(9600); // Initialize serial communication Serial.println("PIR Sensor Warm-up initiated..."); // Give the sensor 30-60 seconds to warm up and stabilize delay(30000); Serial.println("Sensor Active."); void loop() val = digitalRead(PIR_PIN); // Read the sensor output state if (val == HIGH) // Check if the sensor output is HIGH digitalWrite(LED_PIN, HIGH); // Turn the onboard LED ON if (sensorState == LOW) // Print to monitor only on the transition from LOW to HIGH Serial.println("--- MOTION DETECTED! ---"); sensorState = HIGH; else digitalWrite(LED_PIN, LOW); // Turn the onboard LED OFF if (sensorState == HIGH) // Print to monitor only on the transition from HIGH to LOW Serial.println("Motion ended. Scanning..."); sensorState = LOW; Use code with caution. 5. Troubleshooting Common Issues