In this tutorial we are going to learn hoe to make a simple obstacle sensing system with cheap parts like (IR LED and Photo Diode)

COMPONENTS


  • IR transmitter (generic)
  • Photo Diode 
  • Arduino UNO & Genuino UNO 
  • 3k resistor 
  • 150 ohm resistor 
  • Breadboard (generic) 
  • Jumper wires (generic) 
  • LED (generic) 


 Circuit Diagram:


Assemble
  • IR LED Anode => 150 ohms resistor => 5v
  • IR Cathode => GND
  • PhotoDiode Anode => GND
  • PhotoDiode Cathode => 3k ohms resistor => D2
  • PhotoDiode Cathode => A0
  • Green LED => D13
  • Red LED => D12

SOURCE CODE:

int photoDiode=2;                      

int GreenLed=13;                     

int senRead=0;                  

int SenseRate=905;                   

 void setup()    

 {  

  pinMode(photoDiode,OUTPUT);  

  pinMode(GreenLed,OUTPUT);

  pinMode(12,OUTPUT);

  digitalWrite(photoDiode,HIGH);       

  digitalWrite(GreenLed,LOW);      

  Serial.begin(9600);           

 }  

 void loop()  

 {  

  int val=analogRead(senRead);    

  Serial.println(val);            

  if(val <= SenseRate)               

  {

   digitalWrite(12,HIGH);  

   digitalWrite(GreenLed,LOW);       

   delay(20);  

  }  

  else if(val > SenseRate)            

  {  

   digitalWrite(12,LOW);

   digitalWrite(GreenLed,HIGH);       

   delay(20);  

  }  

 }  



BY
       REGU RAM SV.

Post a Comment

Previous Post Next Post