The infrared sensor used in Lesson 12 and some projects is a simple, 3-pin device. Yet a common complaint from students is, "it doesn't work."

 

Most often this is because the schematic diagram is interpreted as a pictorial. The schematic diagram in Lesson 12 appears to show the middle lead of the sensor going to the Arduino digital pin and the two outside pins going to +5 volts and ground. THIS IS WRONG! Remember, a schematic is not a pictorial.

 

Earlier in the Lesson is a picture of an IR sensor that identifies which lead has which number. Here's how to determine which lead goes where:

 

  1. Hold the sensor in your hand with the raised "bump" or circle facing you, and the leads going down. You are now looking at the front of the sensor.
  2. Look at the lead to your LEFT. It is number 1 and is to be connected to the Arduino digital pin.
  3. Look at the lead in the MIDDLE. It is number 2 and is to be connected to ground.
  4. Look at the lead to your RIGHT. It is number 3 and is to be connected to +5v.

 

CAUTION: incorrect connection can damage an infrared sensor. By damaged is meant won't work and should be thrown away.

 

HOW TO TEST AN INFRARED SENSOR

To test your IR sensor you need a voltmeter and a working infrared remote control, such as might be used for a television set. The steps are:

 

  1. Connect the IR sensor pin 1 (the LEFT one as it faces you) to the positive lead of the voltmeter.
  2. Connect the IR sensor pin 2 (the MIDDLE one) to ground on the Arduino.
  3. Connect the IR sensor pin 3 (the RIGHT one as it faces you) to +5v on the Arduino.
  4. Connect the voltmeter negative lead to ground on the Arduino.
  5. Connect the Arduino to power. Plugging it into a computer's USB port is an easy way to do this.
  6. Set the voltmeter to read DC voltage with a range greater than 5 volts.
  7. Look at the voltage being displayed on the voltmeter. It should be very close to 5 volts. By "very close" is meant within 1/10th volt.
  8. While watching the voltmeter point the remote control at the IR sensor then press and hold one of the buttons. If the voltage drops significantly the sensor is working. By dropping significantly is meant the voltage is 4.8 volts or lower.