hi, how are you today
Let's learn how to interface a LDR sensor with our baby (8051uC)
For enhance concept just visit www.salahtutorials.com
Let's learn how to interface a LDR sensor with our baby (8051uC)
Description
This article helps you to understand the concept behind the interfacing of LDR(Light Dependent Resistor). The value of resistance is totally depends upon the light. With increase in light on ldr resistance decreases and vice versa and the same is shown in video below.Sensors are basically input device that provide us the input signal when they sense the thing for which they are designed. Here I will show you how to read input from a ldr sensor and how to control output with that input pulse.Programming
1: #include<reg51.h> // header file
2: void delay(int time) // function to generate delay
3: {
4: int i,j;
5: for(i=0;i<=time;i++) // i will run from 0 to user defined value
6: for(j=0;j<=1275;j++); // j will run from 0 to 1275 "time" times
7: }
8: sbit sensor=P3^0;
9: sbit led=P3^1;
10: /*if sensor transmits high pulse*/
11: void main() // main function
12: {
13: led=0; // setting led initially off
14: sensor=0;// putting sensor pin to 0 so that we can read high pulse
15: while(1) // while(1)used to provide continuous loop
16: {
17: if(sensor==1) // if sensor provides high input
18: {
19: led=1; // light will be on
20: delay(200) // light will remain on for this specified delay
21: led=0; // light will off and again on when sensor will be 1
22: }
23: }
24: }
For enhance concept just visit www.salahtutorials.com
Hope you all like this post and I wish this must be useful for you.
Thanks :)
Comments
Post a Comment