mercredi 6 avril 2016

IR Led using PIc 16f877


In this post I am going to show you how to use and program IR LED with too pic 16f877a

IR LED:

IR LED means Infrared Light Emitting Diode. The IR LED emits Infrared light which is not visible to human eye. we can find these IR LED's in our TV Remotes. IR LED's works like normal LED's but the material used in the core is different, it emits Infrared Light when current passed through it.


Photodiode:

Photodiode is a light sensitive semi-conductor diode which converts the light energy into voltage or current based on the mode of operation. In general Photodiodes are operated in reverse bias condition. The clear Photodiode can detect visible and IR rays to limit the Photodiode to detect only IR rays a black cotting is applied to the glass of the Photodiode. The photodiode allows the current to pass through it if the photodiode is exposed to IR rays and it doesn't allow current to pass through it if no IR rays falls on it. The amount of current passed through the photodiode is directly proportional to amount of IR rays falls on it.



Materials required:

1) 2*Pic      16f877a              
2) IR LED   
                   
3) 3*Button                     
4) 4*Capacitor 22p
5) 2*Quartz 4 MHZ
6) Led Red
7)3*Resistance 220hom

Circuit diagram:



Program :

EM:


#include<16F877A.h>
#device adc=10
#fuses HS
#use delay (clock=8M)
#byte portb=6
#byte trisb=0X86
#bit bouton1=portb.0

 void main()
  {
   port_b_pullups(true);
   setup_timer_2(T2_div_by_1,52,1);//pwm period=Tosc*4*mode*(periode+1)=0,125*4*1x=26,3 us
   //0,5x=26,3
   //x=26,3:0,5=53
    set_pwm1_duty(48);
   
    while(true)
     {if(bouton1==0)
         {
          setup_ccp1(ccp_pwm);
          delay_ms(100);
          setup_ccp1(ccp_off);
          delay_ms(100);
          }
     }
  }

RE

#include<16F877A.h>
#device adc=10
#fuses HS
#use delay (clock=8M)
#byte portb=6
#byte trisb=0X86
#bit bouton1=portb.0
#byte portd=8
#byte trisd=0x88
#bit led=portd.0
#bit data=portb.0

int1 i;
 void main()
  {
   port_b_pullups(true);
      trisb=0Xff;
      i=0;
      trisd=0X00;
      portd=0;
      while(true) //recepteur
       {
        if(data==0)
          {
           //delay_ms(200);
           if(data==0)
               {
                delay_ms(51);
                 if(data==0)
                    {i++;
                    
                     if (i==1)
                      led=1;
                       else
                       { led=0;}
                    }    
                   
          
                 }
           }
  
        }
  }

 Video :























Continue Reading...