 //loop function:
 void loop() 
 { //al
-  alsensor = analogRead(alinput); //read the sensor value
-  albrightness = alsensor / 4; //convert the value from 10-bit resolution to 8-bit res
-  alvoltage = alsensor * (5.0 / 1024.0); //convert the value into actual voltage range 0-5V
-  Serial.print("The voltage is: ");  //prints the voltage through serial
-  Serial.println(alvoltage);
-  analogWrite(aloutput,albrightness); //output the PWM to the LED
-  while(digitalRead(alinterrupt)) //interrupt function
-  { if(digitalRead(aloverride)) //override - ON
+  if(!digitalRead(aloverride))
+  { alsensor = analogRead(alinput); //read the sensor value
+    albrightness = alsensor / 4; //convert the value from 10-bit resolution to 8-bit res
+    alvoltage = alsensor * (5.0 / 1024.0); //convert the value into actual voltage range 0-5V
+    Serial.print("The voltage is: ");  //prints the voltage through serial
+    Serial.println(alvoltage);
+    analogWrite(aloutput,albrightness); //output the PWM to the LED
+  }
+  else //override function
+  { if(digitalRead(altoggle)) //toggle - ON
      analogWrite(aloutput,255);
-    else //override - OFF
+    else //toggle - OFF
      analogWrite(aloutput,0);
   }
   delay(500);
   
   //el
-  elsensor=analogRead(elinput);
-  if((elsensor>treshold) && (elstate==0))
-  { digitalWrite(eloutput,HIGH);
-    Serial.println("External light is ON");
-    elstate=1;
+  if(!digitalRead(eloverride))
+  { elsensor=analogRead(elinput);
+    if((elsensor>treshold) && (elstate==0))
+    { digitalWrite(eloutput,HIGH);
+      Serial.println("External light is ON");
+      elstate=1;
+    }
+    else if((elsensor<treshold) && (elstate==1))
+    { digitalWrite(eloutput,LOW);
+      Serial.println("External light is OFF");
+      elstate=0;
+    }
   }
-  else if((elsensor<treshold) && (elstate==1))
-  { digitalWrite(eloutput,LOW);
-    Serial.println("External light is OFF");
-    elstate=0;
+  else //override function
+  { if(digitalRead(eltoggle));
+    { digitalWrite(eloutput,HIGH);
+      Serial.println("External light is ON-toggle");
+    }
+    else
+    { digitalWrite(eloutput,LOW);
+      Serial.println("External light is OFF-toggle");
+    }
   }
-  while(digitalRead(elinterrupt)) //interrupt function
-  { digitalWrite(eloutput,digitalRead(eloverride));
-   Serial.println("External light is ON-Override");
-  }
-  delay(500);
     
   //pc
-  pcsensor = digitalRead(pcinput);
-  if(pcsensor!=pcstate)
-  {
-    if(pcsensor == 1)
-    { digitalWrite(pcoutput,HIGH);
-      Serial.println("Motor is ON");
-      pcstate = pcsensor;
-    }
-    else
-    { digitalWrite(pcoutput,LOW);
-      Serial.println("Motor is OFF");
-      pcstate = pcsensor;
+  if(!digitalRead(pcoverride))
+  { pcsensor = digitalRead(pcinput);
+    if(pcsensor!=pcstate)
+    { if(pcsensor == 1)
+      { digitalWrite(pcoutput,HIGH);
+        Serial.println("Motor is ON");
+        pcstate = pcsensor;
+      }
+      else
+      { digitalWrite(pcoutput,LOW);
+        Serial.println("Motor is OFF");
+        pcstate = pcsensor;
+      }
     }
   }
-  while(digitalRead(pcinterrupt)) //interrupt function
-   digitalWrite(pcoutput,digitalRead(pcoverride));
-  delay(500);
+  else //override function
+  { pcsensor = digitalRead(pctoggle);
+    if(pcstate!=pcsensor)
+    { if(pcsensor == 1)
+      { digitalWrite(pcoutput,HIGH);
+        Serial.println("Motor is ON - toggle");
+        pcstate = pcsensor;
+      }
+      else
+      { digitalWrite(pcoutput,LOW);
+        Serial.println("Motor is OFF - toggle");
+        pcstate = pcsensor;
+      }
+    }
+  }
+  
   
   //tm
   tm=analogRead(tminput);//read the temperature value

{
  Serial.begin(9600);
  //al
  pinMode(alinterrupt,INPUT);
  pinMode(aloverride,INPUT);
  //el
  pinMode(eloutput,OUTPUT);
  pinMode(elinterrupt,INPUT);
  pinMode(eloverride,INPUT);
  elstate=0;
  //pc
  pinMode(pcinput,INPUT);

==== ======
rev v.1

adaptive lighting
al-adaptive lighting

external lighting
el-external lighting

water pump system
pc-pumpcontrol

temperature mesuring system
tm-temperature measurement

preprosessor definitions:
al
*/


#define alinput A0
#define aloutput 9
#define aloverride 2
#define altoggle 3

//el
#define elinput A1
#define eloutput 10
#define treshold 500
#define eloverride 4
#define eltoggle 5

//pc
#define pcinput A2
#define pcoutput 11
#define pcoverride 6
#define pctoggle 7

//tm
#define tminput A3
