Guest User

Untitled

a guest
Apr 25th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.04 KB | None | 0 0
  1. /*
  2. #
  3.  #  Name of the Project:
  4.  #  Date:
  5.  #  Some more random information regaring the history of the universe ^^
  6.  #
  7.  */
  8.  
  9. int SensorReading;
  10. int LightReading;
  11. int ledPin     = 3;
  12. int BigDelay   = 5000;
  13. int FadeDelay  = 50;
  14. int LightSense = 250;
  15. int BuzzerPin  = 5;
  16.  
  17. void setup() {                
  18.   Serial.begin(9600);
  19.   pinMode(ledPin,OUTPUT);
  20. }
  21.  
  22. void loop() {
  23.  
  24.   LightReading  = analogRead(A5);
  25.   SensorReading = analogRead(A2);  
  26.   Serial.print("Presence sensor: ");
  27.   Serial.print(SensorReading);
  28.   Serial.print(" - Light sensor: ");
  29.   Serial.println(LightReading);
  30.   delay(50);
  31.  
  32.  
  33.   if (SensorReading>600) {
  34.     if(LightReading>LightSense) {
  35.       analogWrite(5,125);
  36.       delay(BigDelay);
  37.     }
  38.     else{
  39.       for(int i=0;i<255;i++){
  40.         analogWrite(ledPin,i);
  41.         delay(FadeDelay);
  42.       }
  43.       delay(BigDelay);
  44.  
  45.       for(int i=255;i>0;i--){
  46.         analogWrite(ledPin,i);
  47.         delay(FadeDelay);
  48.       }
  49.     }  
  50.   }
  51.  
  52.   else {
  53.     digitalWrite(ledPin,LOW);
  54.     analogWrite(5,0);
  55.   }
  56.  
  57. }
Add Comment
Please, Sign In to add comment