🛠️

Arduino Uno with Infrared Sensor Module Tutorial

Jul 13, 2024,

Arduino Uno with Infrared Sensor Module

Introduction

  • Demonstration of using an Arduino Uno with an infrared sensor module.
  • Components needed:
    • Arduino Uno
    • Infrared sensor module
    • 3 male to female jumper wires

Connections

  1. Connect VCC and ground pin of the infrared sensor module to 5V and ground pin of Arduino Uno respectively.
  2. Connect the output pin of the infrared sensor module to pin 12 of Arduino Uno.

Arduino IDE Setup

  • void setup(): Define pins
    • Use pin 12 as the input pin (digital pins can be used)
    • Use pin 13 as the output pin (built-in LED connected to pin 13)
  • void loop(): Detect sensor value
    • Infrared sensor gives a low value upon object detection
    • Use if statement to check object detection at pin 12
      • If detected (digital read at pin 12 == low), turn pin 13 high
      • Else, keep pin 13 low

Code Upload

  1. Compile the code.
  2. Plug Arduino into computer using USB cable.
  3. Select correct board and communication port.
  4. Upload code to Arduino.
  5. Upon detection of an object, the sensor will send a low signal and turn on the built-in LED connected to pin 13.

Adjusting Sensor Range

  • Use a screwdriver to adjust the potentiometer on the sensor.
  • Turning in one direction decreases the range; the other direction increases it.

Conclusion

  • Like, share, and subscribe.
  • Take care and Allah Hafiz.