top of page

LED control with LDR & arduino UNO

Writer's picture: nik patelnik patel

hey there!, in this post i will show you how to control led using ldr & arduino UNO


Component required

Arduino Uno

LED

LDR (photoresistor)

220 and 10k ohm resistors

Wires

Breadboard




Connection diagram of LED, LDR, & ARDUINO UNO:






Upload the code to arduino:

const int ledPin = 13;

const int ldrPin = A0;

void setup() {

Serial.begin(9600);

pinMode(ledPin, OUTPUT);

pinMode(ldrPin, INPUT);

}

void loop() {

int ldrStatus = analogRead(ldrPin);

if (ldr Status <=300) {

digitalWrite(ledPin, HIGH);

Serial.println("LDR is DARK, LED is ON");

}

else {

digitalWrite(ledPin, LOW);

Serial.println("---------------");

}

}


Result:





23 views0 comments

Recent Posts

See All

Comments


Post: Blog2_Post

Subscribe Form

Thanks for submitting!

  • Instagram
  • Twitter

©2020 by electronikproject.

bottom of page