The Alpha Geek – Geeking Out

Project #7: RGB LCD Shield – IR Emitters and Detectors – Mk04

Infrared Emitters and Detectors

Side-looking Infrared Emitters and IR Detectors. These simple devices operate at 940nm and work well for generic IR systems including remote control and touch-less object sensing. Using a simple ADC on any microcontroller will allow variable readings to be collected from the detector. The emitter is driven up to 50mA with a current limiting resistor as with any LED device. The detect is a NPN transistor that is biased by incoming IR light.

Sold as a pair, with one Emitter and one Detector.

IR Emitter

Connect IR LED using a 270 ohm series resistor to the +5 supply (or to an Arduino pin if you want to switch the source on and off). Current draw is about 11 mA with a 270 ohm resistor. Current runs from anode to cathode. Flat on the case marks the cathode. To determine if the IR LED is the right way around.

IR Detector

A IR Detector is just like a regular transistor except the base lead is disabled or absent and light activates base current. The flat on the case marks the collector, the other lead is the emitter. Connect the collector to one end of a 10K ohm resistor and connect the other end of the resistor to a +5V supply (you can use the +5 pin on the Arduino). Connect the emitter to ground. The voltage should start out at +5V. When pointing the IR Detector, the voltage should drop down to near zero. To interface with the Arduino, make a second connection from the collector to an Arduino pin.

DonLuc1807Mk08

1 x RGB LCD Shield 16×2 Character Display
1 x Arduino UNO – R3
1 x ProtoScrewShield
1 x IR Emitter
1 x IR Detector
1 x 270 ohm resistor
1 x 10k ohm resistor
3 x Jumper Wires 3″ M/M
4 x Jumper Wires 6″ M/M
1 x Half-Size Breadboard

Arduino UNO

Det – Analog A0
Emi – Digital 2
VIN – +5V
GND – GND

DonLuc1807Mk08p.ino

// ***** Don Luc *****
// Software Version Information
// Project #7: RGB LCD Shield – IR Emitters and Detectors – Mk04
// 7-8
// DonLuc1807Mk08p 7-8
// RGB LCD Shield
// IR Emitters and Detectors

// include the library code:
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();
#define GREEN 0x2

// IR Emitters and Detectors
int iDet = 2;
int iSense = A0;
int iVal;

void loop() 
{

  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("IR Emi - Det");     // IR Emitters and Detectors
  
  // IR Emitters and Detectors
  iVal = analogRead(iSense);
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  if ( iVal >= 1005 ) 
  {
     RGBLCDShield.print("Alarm");         // Alarm    
  }
  else
  {
     RGBLCDShield.print("No");            // No
  }
  
  delay(1000);
  
  // Clear
  RGBLCDShield.clear();
  
}

setup.ino

// Setup
void setup() 
{

  // set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);
  RGBLCDShield.setBacklight(GREEN);
  
  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);  
  RGBLCDShield.print("Don Luc");         // Don luc
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("IR Emi - Det");    // IR Emitters and Detectors

  delay(5000);

  // Clear
  RGBLCDShield.clear();

  // IR Emitters and Detectors
  pinMode(iDet, OUTPUT);
  pinMode(iSense, INPUT);
  digitalWrite(iDet,HIGH);

}

Don Luc

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories
Archives