Guest User

Untitled

a guest
Jul 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. const int ledPin = 13;const int ldrPin = A0;void setup() {
  2.  
  3. Serial.begin(9600);
  4.  
  5. pinMode(ledPin, OUTPUT);
  6.  
  7. pinMode(ldrPin, INPUT);
  8.  
  9. }
  10.  
  11. void loop() {
  12.  
  13. int ldrStatus = analogRead(ldrPin);
  14.  
  15. if (ldrStatus <= 200) {
  16.  
  17. digitalWrite(ledPin, HIGH);
  18.  
  19. Serial.print("Its DARK, Turn on the LED : ");
  20.  
  21. Serial.println(ldrStatus);
  22.  
  23. } else {
  24.  
  25. digitalWrite(ledPin, LOW);
  26.  
  27. Serial.print("Its BRIGHT, Turn off the LED : ");
  28.  
  29. Serial.println(ldrStatus);
  30.  
  31. }
  32.  
  33. }
Add Comment
Please, Sign In to add comment