Stufin
Home Quick Cart Profile

IR Proximity Sensor ( Pack of 25)

Buy Now

Pin Configuration

  • IR Proximity Sensor (Pack of 25) - Pinout Explanation and Connection Guide
  • The IR Proximity Sensor is a compact and affordable sensor module designed to detect objects or obstacles within a certain range. This documentation provides a detailed explanation of the sensor's pins and a step-by-step guide on how to connect them.
  • Pinout:
  • The IR Proximity Sensor has a total of 3 pins, each with a specific function:
  • Pin 1: VCC (Power Supply)
  • Function: Provides power to the sensor module
  • Recommended voltage range: 3.3V to 5V
  • Typical current consumption: 10mA to 20mA (dependent on the operating voltage)
  • Pin 2: OUT (Output)
  • Function: Provides a digital output signal indicating the presence or absence of an obstacle
  • Output type: Digital (0V or VCC)
  • Output logic:
  • + 0V (LOW): Indicates the presence of an obstacle
  • + VCC (HIGH): Indicates no obstacle detected
  • Pin 3: GND (Ground)
  • Function: Provides a ground connection for the sensor module
  • Connect to the negative terminal of the power supply or the ground pin of a microcontroller
  • Connection Guide:
  • To connect the IR Proximity Sensor to a microcontroller or a development board, follow these steps:
  • Step 1: Power Connection
  • Connect Pin 1 (VCC) to a 3.3V or 5V power supply
  • Ensure the power supply is stable and within the recommended voltage range
  • Step 2: Ground Connection
  • Connect Pin 3 (GND) to the negative terminal of the power supply or the ground pin of a microcontroller
  • Ensure a solid ground connection to prevent sensor malfunction
  • Step 3: Output Connection
  • Connect Pin 2 (OUT) to a digital input pin on a microcontroller or a development board
  • Use a pull-up resistor (optional) to ensure a high output level when no obstacle is detected
  • Note:
  • When connecting the sensor to a microcontroller, ensure the output pin is configured as a digital input.
  • The sensor's output signal is active LOW, meaning it will output 0V when an obstacle is detected and VCC when no obstacle is detected.
  • Adjust the power supply voltage according to the sensor's specifications to ensure accurate and reliable operation.
  • By following these connection guidelines, you can successfully integrate the IR Proximity Sensor into your IoT project and take advantage of its accurate and reliable object detection capabilities.

Code Examples

IR Proximity Sensor (Pack of 25) Documentation
Overview
The IR Proximity Sensor is a compact and versatile sensor that detects objects or people within a certain range using infrared technology. This sensor is ideal for various applications, including robotics, smart home automation, and interactive installations. This pack of 25 sensors is perfect for prototyping, proof-of-concept projects, or large-scale deployments.
Pinout and Connections
The IR Proximity Sensor has three pins:
VCC: Power supply (3.3V to 5V)
 GND: Ground
 OUT: Digital output (HIGH or LOW)
Technical Specifications
Detection range: 10 cm to 80 cm (adjustable)
 Supply voltage: 3.3V to 5V
 Output type: Digital (TTL compatible)
 Response time: 10 ms
 Power consumption: 5 mA (typical)
Code Examples
### Example 1: Basic Obstacle Detection (Arduino)
In this example, we'll connect the IR Proximity Sensor to an Arduino board to detect obstacles within a certain range.
```arduino
const int sensorPin = 2;  // Digital input pin for the sensor
const int ledPin = 13;   // Built-in LED pin for indication
void setup() {
  pinMode(sensorPin, INPUT);
  pinMode(ledPin, OUTPUT);
}
void loop() {
  int sensorState = digitalRead(sensorPin);
  if (sensorState == HIGH) {
    digitalWrite(ledPin, HIGH);  // Turn on the LED if an obstacle is detected
  } else {
    digitalWrite(ledPin, LOW);   // Turn off the LED if no obstacle is detected
  }
  delay(50);
}
```
### Example 2: Smart Home Automation (Raspberry Pi with Python)
In this example, we'll use the IR Proximity Sensor with a Raspberry Pi to trigger a relay module when an object is detected within a certain range.
```python
import RPi.GPIO as GPIO
import time
# Set up GPIO mode
GPIO.setmode(GPIO.BCM)
# Define sensor and relay pins
sensorPin = 17
relayPin = 18
# Set up sensor pin as input and relay pin as output
GPIO.setup(sensorPin, GPIO.IN)
GPIO.setup(relayPin, GPIO.OUT)
while True:
    sensorState = GPIO.input(sensorPin)
    if sensorState == 1:
        print("Object detected!")
        GPIO.output(relayPin, GPIO.HIGH)  # Turn on the relay
    else:
        print("No object detected.")
        GPIO.output(relayPin, GPIO.LOW)   # Turn off the relay
    time.sleep(0.1)
```
### Example 3: Interactive Installation ( CircuitPython with Micro:bit)
In this example, we'll use the IR Proximity Sensor with a Micro:bit board to create an interactive installation that displays a message on the LED matrix when an object is detected.
```python
import microbit
import utime
# Define sensor pin
sensorPin = microbit.pin0
while True:
    sensorState = sensorPin.read_digital()
    if sensorState == 1:
        microbit.display.scroll("Hello!")  # Display a message on the LED matrix
        utime.sleep(1)  # Wait for 1 second
    utime.sleep(0.1)  # Check the sensor every 0.1 seconds
```
Important Notes
Make sure to adjust the sensor's detection range according to your specific application requirements.
 Use a suitable power supply for the sensor, and ensure that it operates within the recommended voltage range.
 When using the sensor with microcontrollers, ensure that the output pin is compatible with the microcontroller's input voltage threshold.