Grove - IR Distance Interrupt

From Wiki
Jump to: navigation, search

Introduction

This IR Distance Interrupter features a high-sensitivity RFR-359F photoreflector to perform distance detection function. The photoreflector consists of a GaAs infrared light emitting diode and a silicon planar phototransistor. When the infrared light emitted by the emitter gets reflected on a surface that blocked it, the phototransistor can pick up the signal for distance calculation. This module is panel mounted so that you can easily implement it on the surface of robots or other projects without wiring clutter. Also a potentiometer for adjustment and an indicator LED are arranged on the back for easy and clear use.


IR Distance Interrupter.jpg


Features

High sensitivity photoreflector Lightweight and compact Panel mount design for clean and tidy implementation Clear HID design: adjustment potentiometer and indicator LED Application Ideas

Wanderer robots RPM gauges Approximation detection Specification

Power supply 5V DC Connector 4 pin Buckled Grove interface Compatibility Compatible with Arduino Digital output mode TTL ( Low when light is detected) Dimension 20mm*20mm ROHS YES Interface


IR Distance Interrupt Interface.jpg


Reflective photosensor: High resolution Infrared Reflective sensor.

LM393: Rail-to-Rail Operational Amplifier.

Indicator LED: The LED will turn on when the received infrared light intensity exceeds a preset level.

Sensitivity adjusting potentiometer : Adjust the light threshold of the sensor.

Usage

With Arduino Let's test the function of detecting whether somebody is here.

1. Plug the Grove-IR Distance Sensor onto port D6 of the Grove - Base Shield;

2. Hold the sensor Sensor facing the empty dark area above the background as show below.


Reflective photosensor3.jpg

Reflective photosensor2.jpg


Reflective photosensor1.jpg



3. Adjust the potentiometer with a crosshead screwdriver until the indicator LED just change from on to off.


Under the adjustment state


Complete the adjustment

4. Create an Arduino sketch and copy the program below to it. void setup() {

 Serial.begin(9600);
 pinMode(6,INPUT);

} void loop() {

 while(1)  {
   delay(500);
   if(digitalRead(6)==LOW)  {
     Serial.println("Somebody is here.");
   }
   else  {
     Serial.println("Nobody.");
   }
 }

} 5.Upload the code.If you do not know how to upload ,please click here. You can see the result as show below.


IMG 20121008 173544.jpg


IMG 20121008 173651.jpg



Nobody


There has somebody

When somebody is here,Indicator Led will be light and the Serial Monitor will output "Somebody is here.".

Or,The Indictor LED is off and the Serial Monitor output "Nobody.".

With Raspberry Pi 1.You should have got a raspberry pi and a grovepi or grovepi+. 2.You should have completed configuring the development enviroment, otherwise follow here. 3.Connection Plug the sensor to grovepi socket D4 by using a grove cable. 4.Navigate to the demos' directory:

  cd yourpath/GrovePi/Software/Python/

To see the code

  nano grove_infrared_distance_interrupt.py    # "Ctrl+x" to exit #

import time import grovepi

  1. Connect the Grove Infrared Distance Interrupt Sensor to digital port D4
  2. SIG,NC,VCC,GND

sensor = 4

grovepi.pinMode(sensor,"INPUT")

while True:

   try:
       # Sensor returns LOW and onboard LED lights up when the
       # received infrared light intensity exceeds the calibrated level
       if grovepi.digitalRead(sensor) == 0:
           print "found something"
       else:
           print "nothing"
       time.sleep(.5)
   except IOError:
       print "Error"

5.Run the demo.

  sudo python grove_infrared_distance_interrupt.py


File:LM393.pdf


File:Reflective photosensor.pdf