#define LED1 3 //defining lamp 1 at pin 3
#define LED2 4 //defining lamp 2 at pin 4
#define LDR1 A0 //defining sensor 1 at pin A0
#define LDR2 A1 //defining sensor 2 at pin A1
void setup() {
//declaring pin status
Serial.begin(9600); //communication begin using serial rate 9600
pinMode(LED1, OUTPUT); //declaring lamp 1 as OUTPUT
pinMode(LED2, OUTPUT); //declaring lamp 2 as OUTPUT
}
void loop(){
//repeated program
if((analogRead(LDR1)) >= 70){ //if sensor 1 reads its value is larger equals to 70
digitalWrite(LED1, HIGH); //executing the command above by turn lamp 1 HIGH
}
if((analogRead(LDR2)) >= 70){ //if sensor 2 reads its value is larger equals to 70
digitalWrite(LED2, HIGH); //executing the command above by turn lamp 1 HIGH
}
else
//no conditions are fulfilled in void loop
{
mati(); //function to run
}
}
void mati(){
//running the function
digitalWrite(LED1, LOW); //executing output 1 and turning into LOW
digitalWrite(LED2, LOW); //executing output 2 and turning into LOW
}