How to use an IR sensor with arduino

Written by steve aycock
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to use an IR sensor with arduino
Use an IR sensor with an Arduino to receive remote control signals. (remote controls image by Wolszczak from

The Arduino open-source electronics and embedded processor platform can be used to control and monitor an infrared sensor. IR sensors can be used to detect proximity, receive communication signals and even detect movement of a person. The Arduino can be programmed to monitor an IR sensor and react to a sensed IR level. Whether you choose an IR sensor with a digital output or one with an analogue output, using an IR sensor with your Arduino requires little, if any, external components and only a few lines of code.

Skill level:

Things you need

  • Arduino development platform

Show MoreHide


  1. 1

    Select an IR sensor. There are different types of IR sensors for various purposes, such as remote control, proximity detection, communication and human motion detection. Pick the IR sensor best suited to your application.

  2. 2

    Connect the IR sensor to the Arduino. Depending on the type of output provided by the IR sensor that you have selected, choose an appropriate input pin on the Arduino. For example, if your IR sensor outputs an analogue signal, you may want to connect the IR sensor to pin A0 of your Arduino, which can serve as an analogue input pin.

  3. 3

    Program the Arduino. Write code to read the IR sensor value that is being input to the pin of the Arduino. For example, if you have an IR sensor with an analogue output connected to pin A0 of the Arduino, you could include a code line such as "int IRsensorValue = analogRead(A0);" in your program. The variable IRsensorValue will contain a value representing the analogue-to-digital conversion of the signal applied to A0.

  4. 4

    Test the IR sensor and Arduino together. After you've transferred your program to the Arduino according to the manufacturer's specifications, you're ready to test. To make testing easier, you may want to provide some form of visual output (such as an LED connected to the Arduino) to indicate a change in state of the IR sensor. If your Arduino and IR sensor do not appear to work correctly, check the circuit connections and check your program to make sure your code is reading the correct pin of the Arduino in the correct mode (digital or analogue).

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.