Advertisement
belrey10

Advance Night Light

Apr 15th, 2020
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. int prPin = 2;
  2. int relayPin = 1;
  3. int lightLevel;
  4.  
  5. void setup() {
  6.   // put your setup code here, to run once:
  7. pinMode(relayPin, OUTPUT);
  8. Serial.begin(9600);
  9.  
  10. }
  11.  
  12. void loop() {
  13.   // put your main code here, to run repeatedly:
  14.  
  15. lightLevel = analogRead(prPin);
  16. Serial.println(lightLevel);
  17.  
  18. if (lightLevel > 900)
  19. {
  20.   digitalWrite(relayPin, HIGH);
  21. }
  22.  
  23. else
  24. {
  25.   digitalWrite(relayPin, LOW);
  26. }
  27. delay(2000);
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement