LED/Photocell


how led stay lit when photocell actuated- when actuated again, led turn off?

here code have- led turns off after removing finger off of photocell.


code: [select]
int ldr = 0;

//analog pin ldr connected, here set 0 means a0

int ldrvalue = 0;

//that's variable store ldr values

int light_sensitivity = 570;


//this approx value of light surrounding ldr
void setup()
 {
   {
   serial.begin(9600);            //start serial monitor 9600 buad
   pinmode(13, output);           //we use13 because there built in yellow led in arduino shows output when 13 pin enabled

 delay(3000);
 }
}

void loop()
 {
   ldrvalue = analogread(ldr);

   serial.println(ldrvalue);

//prints ldr values serial monitor                   //this speed ldr sends value arduino
 
 
     
if (ldrvalue < light_sensitivity)
    {
      digitalwrite(13, high);
    }
    else
    {
      digitalwrite(13, low);

    }

     
 }

read how use forum sticky, go , modify post code posted correctly.


Arduino Forum > Using Arduino > Programming Questions > LED/Photocell


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support