មេរៀនទី១៥៖​ Use LDR Sensor Control LED - Tann Thona

Telecommunication and Electronic Engineering

Post

Post Top Ad

Thursday, December 17, 2020

មេរៀនទី១៥៖​ Use LDR Sensor Control LED

LDR Sensor

 

1. Objective

The objective is talk about, how to use LDR sensor to control LED.

2. Requirement

  • Arduino Uno x1
  • USB Cable x1 (No need in simulation)
  • Breadboard x1 (No need in simulation)
  • LED x1
  • Resistor (220 or 330 Ohm) x1
  • Resistor (10K Ohm) x1
  • Electronic Wire (No need in simulation) \
  • LDR Sensor x1

 

3. Build Circuit

Build circuit like Figure 1.


Figure 1. Arduino Connection

 

4. Coding

// by Tann Thona
int ldr = 0;
void setup() {
// put your setup code here, to run once:
pinMode(A0, INPUT);
pinMode(13, OUTPUT);
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
ldr = analogRead(A0);
if(ldr < 512)
{
digitalWrite(13, 1);
}
else
{
digitalWrite(13, 0);
}
Serial.println(ldr);
delay(10);
}

Click Here to Download Code and Proteus Simulation File 

 

4. Result

According to code above, if LDR sensor at dark place so LED is on but if LDR sensor at brightness place so LED is off.

Watch Video Explain in Khmer



YouTube: ICT4D-KH
Copyright By Tann Thona


No comments:

Post a Comment

Post Top Ad