Você está na página 1de 4

15/12/2016

How to Use IR LED and Photodiode with Arduino

How to Use IR LED and Photodiode with Arduino


InthispostIamgoingtoshowyouhowtouseand
programIRLEDandPhotodiodepairwithArduinotodetect
obstaclesinashortrange.Beforegoingtodotheprojectlet
ushaveabrieflookattheIRLEDandPhotodiode.

IRLED:

[http://3.bp.blogspot.com/-3zELL9QGyMw/UZTiY_N2oAI/AAAAAAAAAD0/3W_68AK
mrKA/s1600/ir+led.jpg]

IRLEDmeansInfraredLightEmittingDiode.The
IRLEDemits Infraredlightwhichisnotvisibletohuman
eye.wecanfindtheseIRLED'sinourTVRemotes.IRLED's
workslikenormalLED'sbutthematerialusedinthecoreis
different,itemitsInfraredLightwhencurrentpassed
throughit.TheseIRLEDareusedtodetectobstaclesahead
oftherobot.TheIRLEDemitsIRlightwhichgetsreflected
ifanyobstacleispresentinthedirectionofemittedIRray,
thereflectedIRraycaughtbyPhotodiodewhichcalculates
thereflectedlightstrength.ThehigherthereflectedIR
raystrength,thecloseristheobstacleandviceverse

Photodiode:

Robotix

My hobby projects

http://startrobotics.blogspot.com.ar/2013/05/how-to-use-ir-led-and-photodiode-with-arduino.html

search
1/4

15/12/2016

How to Use IR LED and Photodiode with Arduino

Classic Flipcard Magazine Mosaic Sidebar Snapshot Timeslide


Object Tracking R...

Sun Tracking Sola...

20

How to Make an ...

69

How to Use IR LE...

60

Basic Sensors Us...

[http://4.bp.blogspot.com/kM4yxdSq7vs/UarSSZJkafI/AAAAAAAAAIk/iqGEGGA-kVY/s1600/photodiode.jpg]

List of Robotics/E...

33

GETTING START...

10

Photodiodeisalightsensitivesemiconductor
diodewhichconvertsthelightenergyintovoltageor
currentbasedonthemodeofoperation.Ingeneral
Photodiodesareoperatedinreversebiascondition.The
clearPhotodiodecandetectvisibleandIRraystolimitthe
PhotodiodetodetectonlyIRraysablackcottingisapplied
totheglassofthePhotodiode.Thephotodiodeallowsthe
currenttopassthroughitifthephotodiodeisexposedtoIR
raysanditdoesn'tallowcurrenttopassthroughitifnoIR
raysfallsonit.Theamountofcurrentpassedthroughthe
photodiodeisdirectlyproportionaltoamountofIRraysfalls
onit.

IRLEDandPhotodiodeProject:
InthisprojectIamgoingtoshowyouHowto
usetheIRLEDandPhotodiodepairtodetecttheobstacle
inforntofit.IamgoingtoprogramtheArduinosuchthat,
IfanobstacleispresentbeforetheIRLEDandPhotodiode
pairwithinthethresholdrangethenabuzzerwillring.
[]

Materialsrequired:
1)Arduino2)IRLED3)Piezobuzzer
4)someWires.

Circuitdiagram:

all rights recived. Dynamic Views template. Powered by Blogger.

Robotix

My hobby projects

http://startrobotics.blogspot.com.ar/2013/05/how-to-use-ir-led-and-photodiode-with-arduino.html

search
2/4

15/12/2016

How to Use IR LED and Photodiode with Arduino

Classic Flipcard Magazine Mosaic Sidebar Snapshot Timeslide


Object Tracking R...

Sun Tracking Sola...

20

How to Make an ...

69

How to Use IR LE...

60

Basic Sensors Us...

List of Robotics/E...

33

GETTING START...

10

[http://4.bp.blogspot.com/e91L1mRon8E/UahPZe4fVKI/AAAAAAAAAIM/FVla8AwFN5g/s1600/Ir+photo+ckt.jpg]

Howcircuitworks:
IntheabovecircuitthePhotodiodeisoperatedin
Reversebiasconditioni.e.,thelonglegofphotodiodegoes
togroundandtheshortlegisconnectedto5Voltssupply
through3Kohmsresistor.WhenthephotodiodedetectsIR
raysfromtheIRLEDwhichisreflectedbyanobstaclethe
photodiodeconductsthen,thecurrentgoestotheground
throughthephotodiodeso,thecurrenttotheanalogpinA0
ofArduinoislowsothat,wewillgetlowvalues(around
500)fromtheanalogpinA0ofarduino.IncaseofnoIR
raysfallsonthephotodiodethephotodiodedoesn'tconduct
sothecurrentfromthedigitalpin2goestoanalogpinA0
throughthe3Kohmsresisterso,thereadingsfromthe
analogpinA0ofArduinowillbearound900.

Program:
int pd=2; //Photodiode to digital
pin 2
int buzz=13;

//piezo buzzer to digital pin 13

int senRead=0;

//Readings from sensor to analog pin 0

int limit=850;

//Threshold range of an obstacle

void setup()
{
pinMode(pd,OUTPUT);
pinMode(buzz,OUTPUT);
digitalWrite(pd,HIGH);

//supply 5 volts to photodiode

digitalWrite(buzz,LOW);

//set the buzzer in off mode (initial condit

Serial.begin(9600);

//setting serial monitor at a default baund

all rights recived. Dynamic Views template. Powered by Blogger.

Robotix

void loop()
My hobby projects

http://startrobotics.blogspot.com.ar/2013/05/how-to-use-ir-led-and-photodiode-with-arduino.html

search
3/4

15/12/2016

How to Use IR LED and Photodiode with Arduino

intSidebar
val=analogRead(senRead);
Classic Flipcard Magazine Mosaic
Snapshot Timeslide //variable to store values from the photodi
Object Tracking R...

Serial.println(val);

// prints the values from the sensor in ser

if(val <= limit)

//If obstacle is nearer than the Threshold

{
Sun Tracking Sola...

digitalWrite(buzz,HIGH);

20

// Buzzer will be in ON state

delay(20);
How to Make an ...

69

How to Use IR LE...

60

Basic Sensors Us...

}
else if(val > limit)

//If obstacle is not in Threshold range

{
digitalWrite(buzz,LOW);

//Buzzer will be in OFF state

delay(20);
}
}
List of Robotics/E...

33

GETTING START...

10

Howprogramworks:
TheprogramstartswithInitializingvariables
photodiode'pd'withdigitalpin2,buzzer'buzz'withdigital
pin13,sensorreadings'senRead'toanalogpin0andthe
limitvariableissetto500(readingfromthesensor).Inthe
'voidsetup()'methodthepinmodeisdefindewiththe
function'pinMode(variable,OUTPUT/INPUT)'.Inthe'void
loop()'methodthe'val'variablestoresthereadingsfrom
thesensor.The'Serial.println(val)'methodisusedtoprint
thevaluesfromthesensortotheserialmonitor.Ihadused
anifelseladdertosetthebuzzerinONstatewhenthe
obstacleisintheThresholdrangeotherwisetheBuzzerwill
beinOFFstate.
Ifyouhaveanytroublerelatedtothispostthen,
expressitinthecommentboxbelow.
Related posts :
1)How to make an obstacle avoiding robot
[http://startrobotics.blogspot.com/2013/06/how-to-make-obstacle-avoiding-robot.html]

2) How to use and program the Temperature sensor and Photresistor with
Arduino. [http://startrobotics.blogspot.com/2013/05/basic-sensors-used-inrobotics.html]

3) Getting Started with Robotics [http://startrobotics.blogspot.com/2013/05/gettingstarted-with-robotics.html]

Posted 31st May 2013 by Kranthi Kumar


Labels: IR LED and Photodiode, IR LED and Photodiode with Arduino, IR LED
with Arduino, Photodiode with Arduinio
View
comments

all rights recived. Dynamic Views template. Powered by Blogger.

Robotix

My hobby projects

http://startrobotics.blogspot.com.ar/2013/05/how-to-use-ir-led-and-photodiode-with-arduino.html

search
4/4

Você também pode gostar