daily pastebin goal
19%
SHARE
TWEET

Arduino LDR + LED

a guest Oct 14th, 2017 138 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const int ledPin = 13;
  2. const int ldrPin = A0;
  3.  
  4. void setup() {
  5.   pinMode(ledPin, OUTPUT);  
  6.   pinMode(ldrPin, INPUT);
  7. }
  8.  
  9. void loop() {
  10.  
  11.   int ldrStatus = analogRead(ldrPin);
  12.  
  13.   if (ldrStatus <=300) {
  14.     digitalWrite(ledPin, HIGH);              
  15.     delay(1000);
  16.  
  17.   }
  18.   else {
  19.     digitalWrite(ledPin, LOW);  
  20.   }
  21.   delay(100);
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top