3.3V to 5V
3.3V to 5V
20mA
2-30 cm (0.7-11.8 inches)
Digital (NH or NL)
3.3V to 5V
50ms
20mm x 15mm x 10mm (0.79 inches x 0.59 inches x 0.39 inches)
Applications
Pinout
The HC-89 Interrupt Sensor module typically has a 3-pin interface |
Power supply (3.3V to 5V)
Ground connection
Digital output signal (NH or NL)
The exact pinout may vary depending on the specific module and manufacturer. Always check the datasheet or documentation provided with the module for specific information.
HC-89 Interrupt Sensor Documentation
Overview
The HC-89 Interrupt Sensor is a digital sensor module designed to detect objects or movements, commonly used in robotics, automation, and IoT projects. It features a built-in infrared transmitter and receiver, allowing it to detect objects within a specific range. The sensor operates on a 5V power supply and provides a digital output signal when an object is detected.
Pinouts
VCC: 5V Power Supply
GND: Ground
OUT: Digital Output Signal
Specifications
Operating Voltage: 5V
Operating Current: 5mA
Detection Range: 2-30cm
Output Signal: Digital (High or Low)
Code Examples
### Example 1: Basic Object Detection using Arduino
In this example, we'll use the HC-89 Interrupt Sensor to detect objects using an Arduino board.
```cpp
const int sensorPin = 2; // Connect the OUT pin to digital pin 2 on your Arduino board
void setup() {
pinMode(sensorPin, INPUT);
Serial.begin(9600);
}
void loop() {
int sensorState = digitalRead(sensorPin);
if (sensorState == HIGH) {
Serial.println("Object detected!");
} else {
Serial.println("No object detected.");
}
delay(50);
}
```
### Example 2: Interrupt-based Object Detection using Raspberry Pi (Python)
In this example, we'll use the HC-89 Interrupt Sensor to detect objects using a Raspberry Pi and Python.
```python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
sensor_pin = 17 # Connect the OUT pin to GPIO pin 17 on your Raspberry Pi
GPIO.setup(sensor_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def callback(channel):
print("Object detected!")
GPIO.add_event_detect(sensor_pin, GPIO.FALLING, callback=callback, bouncetime=200)
while True:
time.sleep(1)
```
In this example, we use the `RPi.GPIO` library to set up the GPIO pin as an input and define an interrupt callback function. When the sensor detects an object, the callback function is triggered, printing "Object detected!" to the console.
These examples demonstrate the basic usage of the HC-89 Interrupt Sensor in different contexts. You can modify and build upon these examples to suit your specific IoT project requirements.