LOGIN
Jayant Singh
Electrical and Electronics Engineering student (Project Leader)
 · New DelhiIndia
Edit
Delete
Share
Report
GENERAL

2nd concept :: Using delay function

source code

int ldr = A0;
int brit = 0; 
int led1= 12; 
int led2= 11; 
int ir1=A1; 
int ir2=A2;
void setup() 
{
Serial.begin(9600); 
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
}

void loop(){
Serial.println(analogRead(A0));
Serial.println(analogRead(A1));
brit = analogRead(ldr);
if( brit < 300 ) 
{
  if (digitalRead(A1)==HIGH){
  analogWrite(led1,255); //Streetlight1
    delay(4000);
}
else if (digitalRead(A1)==LOW)
{analogWrite(led1,50);
}
  else if (digitalRead(A2)==HIGH){
    analogWrite(led2,255); //Streetlight2
    delay(4000);
 }
  else if (digitalRead(A2)==HIGH) 
{
    analogWrite(led2,50);
  }
}}

ps : I think 1st concept is more practical
your suggestion ?

2 likes 
Like
Share
Tayyab Hameed
programmer
 · LahorePakistan
Edit
Delete
Share
Report

first concept is good u should go with that

1 like 
Lawal Bayode
ahmad
 · Nigeria
Edit
Delete
Share
Report

preety okay

0 like 
Leave a reply...
DISCOVER
CHAT
ALERTS
-2
DISCUSSIONS
-1
FEED