How To Use IR LED and Photodiode With Arduino
How To Use IR LED and Photodiode With Arduino
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
20
69
60
[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:
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
20
69
60
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;
int senRead=0;
int limit=850;
void setup()
{
pinMode(pd,OUTPUT);
pinMode(buzz,OUTPUT);
digitalWrite(pd,HIGH);
digitalWrite(buzz,LOW);
Serial.begin(9600);
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
intSidebar
val=analogRead(senRead);
Classic Flipcard Magazine Mosaic
Snapshot Timeslide //variable to store values from the photodi
Object Tracking R...
Serial.println(val);
{
Sun Tracking Sola...
digitalWrite(buzz,HIGH);
20
delay(20);
How to Make an ...
69
60
}
else if(val > limit)
{
digitalWrite(buzz,LOW);
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]
Robotix
My hobby projects
http://startrobotics.blogspot.com.ar/2013/05/how-to-use-ir-led-and-photodiode-with-arduino.html
search
4/4