I m making an intruder alrm system using led and light sensor.I want by led to glow continuously after my light sensor has been interrupted for 0nce.How do I do this?
Assuming that you are referring to a break beam or similar light sensor
Check light sensor
If not lit
Turn on LED
Infinite loop
But I assume you want more than this so please give more detail.
Weedpharma
weedpharma:
Assuming that you are referring to a break beam or similar light sensorCheck light sensor
If not lit
Turn on LED
Infinite loopBut I assume you want more than this so please give more detail.
Weedpharma
something that has been ratting around the dust.......
do you want to digitalWrite on every loop ?
does it make any difference, power consumption, anything ?
vs. writing it once ?
if(light_sensor==LOW){
led_Status=HIGH;
}
if (reset==HIGH){
led_Status=LOW;
}
digitalWrite(LED,led_Status)
or is this more efficient as far as the arduino itself is concerned ?
if(light_sensor==LOW){
digitalWrite(LED,HIGH)
}
if (reset==HIGH){
digitalWrite(LED,LOW)
}
prosenjit, can you please clear up what you want ?
the title of this thread says blink, your actual question says lit.
a snippit to flash
long count = 0; // goes above void setup
int blink_flag = 0;
int alarm_flag =0;
// put in void loop
if(sensor=LOW){
alarm_flag=HIGH;
}
if (alarm_flag==HIGH){
count=count+1
if (count>=10000){ //increase value to slow flash rate
count=0; // resets to 0 after it reached the limit
blink_flag= !blink_flag; // alternates from high to low
}
}
digitlaWrite(led,blink_flag) // alternates from high to low
if (reset==HIGH){ // from key or other
digitalWrite(LED,LOW) // turns off led
count=0; // housekeeping
alarm_flag=LOW; // turns off flag
}
since the only way to turn the LED on, is to detect the absence of light, the LED will turn on.
the only way to turn off the LED is for you to reset the unit with a switch or some such.