Guest User

Arduino LDR + LED

a guest
Oct 14th, 2017
306
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×