Toll-Free Customer Support 24/7

light intensity digital i/o code



/*
 * Project name:
     LIGHT  sensor  
 * Copyright
     (c) Researchdesignlab.com
 * Description:
    
 * Test configuration:
     MCU:             AT89S52
     Dev.Board:       8051
     Oscillator:      11.0592 MHz
     Software:        Keil uVision3

*/


#include<reg51.h>  


sbit LDR=P1^0;    
sbit LAMP=P2^0;                    // soil sensor PIN connected P1.0

void DELAY()
    {                                  //delay of 3ms
    unsigned int X=800000;
    while(X--);
    }
    

 void main()
  {
 
    LAMP=0;
        DELAY();
   while(1)
   {
    if(LDR==1)                             
       LAMP=1;
    DELAY();
    }
    else                                
    {
         LAMP=0;
    }
   }


  }

    
   

Back to top