Light dependent resistor is a sensor which is commonly used to detect presence of light. It is used in many experiments for detection purpose, as a burglar alarm. Its value depends on light intensity. It is a type of resistor whose resistance whose value increases when intensity of light increases. Resistance means oppose to any thing. In electronics it indicates oppose to flow of electron. The component or device which has this quality is called as resistor. In Light Dependent resistor, resistance is depend upon amount of light falling onto it.
Working: When there is poor light or no light Resistance of LDR will be maximum. It will strongly oppose to current flow. When there is sufficient light then resistance will be minimum and current flow will be maximum.
In this we are going to measure Light intensity through program.
- Goto mblock software and open it.
- Goto edit menu and select Arduino mode.
Playme Robot Program is a Header file for Robot programming. It makes programming simple. By using this we can access all blocks easily and smoothly. If we are not using this then it may give us errors in program. So put this at start of program.
Figure 8: Loop Selection
Here we are using loop. Loop is area which will be repeated for certain times depending upon its type. If we write anything inside loop then it will be repeated along with loop. Forever loop means program will run continuously. For example if we write a program to run motor in forward direction with forever loop then it will run until we remove power applied to it.
Select block Send to Computer and drag it in programming window.
Put it in forever loop. Here we are writing Hello for message printing. You can write any message instead of Hello.
To get distance of obstacle from playme select Light Value block.
Connect that block to Send to computer .
Connect wait statement of 1second below this.
Now save program.
Give name to program.
Select COM port
Click on Upload Arduino option
After uploading is done you will get this message.
Click on close option.
Again go to Serial port and select COM port
And see output of your program
You can see this response which is not distance. To get proper message select Char mode for both send encode mode, recv encode mode.
And see light sensor value on your screen. It will be displayed on screen after every one second.