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.
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
Post a Comment